Most Popular

1500 questions
465
votes
7 answers

When should you use WP_Query vs query_posts() vs get_posts()?

It seems like half the tutorials in the Codex and around the blogosphere use query_posts() and half use WP_Query. They all do similar things, so when should I use one over the others?
Dan Gayle
  • 6,166
  • 5
  • 33
  • 45
347
votes
108 answers

Best collection of code for your 'functions.php' file

As with many others who are now viewing this post, I have been reading various blogs, forums, and discussion groups to learn and improve my WordPress skills. Over the past 12 months I have been on a mission to substitute my use of plugins by adding…
NetConstructor.com
  • 4,426
  • 18
  • 70
  • 83
214
votes
27 answers

How to: Easily Move a WordPress Install from Development to Production?

I do development on one box and use a second for production. Right now I just dump the database and then do a find a replace for the URL changes; then copy over the files and import the new SQL. Are there better ways of doing this?
Ryan Gibbons
  • 3,067
  • 3
  • 22
  • 19
183
votes
5 answers

Get WordPress post content by post id

How can I get WordPress post content by post id?
m3tsys
  • 2,057
  • 2
  • 15
  • 11
179
votes
5 answers

When to use WP_query(), query_posts() and pre_get_posts

I read @nacin's You don't know Query yesterday and was sent down a bit of a querying rabbit hole. Before yesterday, I was (wrongly) using query_posts() for all my querying needs. Now I'm a little bit wiser about using WP_Query(), but still have some…
saltcod
  • 2,098
  • 3
  • 14
  • 17
167
votes
6 answers

If the current user is an administrator or editor

How can I check to see if the current logged-in user is an administrator or an editor? I know how to do each individually:
andy
  • 2,359
  • 8
  • 25
  • 34
156
votes
10 answers

Is moving wp-config outside the web root really beneficial?

One of the most common security best practices these days seems to be moving wp-config.php one directory higher than the vhost's document root. I've never really found a good explanation for that, but I'm assuming it's to minimize the risk of a …
Ian Dunn
  • 4,887
  • 5
  • 44
  • 70
152
votes
13 answers

Hide the fact a site is using WordPress?

I have a website for which we are trying to be discreet about the fact that we are using WordPress. What steps can we take to make it less obvious? EDIT- Important security note: Please understand that doing this perfectly is impossible as per…
Casebash
  • 1,665
  • 3
  • 12
  • 12
150
votes
7 answers

Is it possible to get a page link from its slug?

Is it possible to get a page's permalink from the slug alone? I'm aware that you can get the page's permalink from the ID using get_page_link(): Map I'm curious if there is any way to do the same with…
Sampson
  • 2,949
  • 5
  • 30
  • 38
147
votes
7 answers

Disable emojicons introduced with WP 4.2

So WP 4.2 introduced emojis (smileys) that basically adds JS and other junk all over your pages. Something some people may find shocking. How does one completely erase all instances of this?
Christine Cooper
  • 8,907
  • 8
  • 60
  • 94
144
votes
5 answers

How to fix pagination for custom loops?

I have added a custom/secondary query to a template file/custom page template; how can I make WordPress use my custom query for pagination, instead of using the main query loop's pagination? Addendum I have modified the main loop query via…
Chip Bennett
  • 55,109
  • 8
  • 91
  • 170
142
votes
8 answers

How do test if a post is a custom post type?

I am looking for a way to test if a post is a custom post type. For example, in, say, the sidebar I can put in code like this: if ( is_single() ) { // Code here } I want code testing for only a custom post type.
Adam Thompson
  • 1,789
  • 2
  • 12
  • 12
142
votes
9 answers

Tips for using WordPress as a CMS?

I want to use WordPress as a CMS for a reasonably basic site rather than a blog. I have several pages and at the moment, I don't intend to have a "news" page. While there are ways to make this work, the focus in the wp-admin console is clearly on…
Damovisa
  • 163
  • 3
  • 3
  • 6
140
votes
17 answers

Adding a Taxonomy Filter to Admin List for a Custom Post Type?

I have created a Custom Post Type called 'listing' and added a Custom Taxonomy called 'businesses'. I would like to add a dropdown list of Businesses to the admin list for the Listings. Here is what this functionality looks like in admin list for…
Taras Mankovski
  • 1,511
  • 3
  • 10
  • 9
140
votes
12 answers

How do I retrieve the slug of the current page?

I am trying to retrieve the slug of the current WordPress page outside the loop. The title of the page returns with wp_title (), but how can I get the slug?
  • sarytash
    • 1,789
    • 3
    • 12
    • 12
    1
    2 3
    99 100