Pieter Goosen
  • Member for 8 years, 9 months
  • Last seen more than 5 years ago
  • South Africa
Allow HTML in excerpt
Accepted answer
142 votes

COMPLETE GUIDE TO EXCERPTS I've recently answered a few questions regarding excerpts, so I'm going to give a detailed explanation covering as much as I can. PREFACE There seems to be a couple of ...

View answer
Remove "Category:", "Tag:", "Author:" from the_archive_title
Accepted answer
117 votes

You can extend the get_the_archive_title filter which I've mentioned in this answer add_filter( 'get_the_archive_title', function ($title) { if ( is_category() ) { ...

View answer
When should you use WP_Query vs query_posts() vs get_posts()?
87 votes

query_posts - You should never ever use query_posts. Apart from what @Rarst has said, the really big issue with query_posts is, it breaks the main query object ( stored in $wp_query ). A lot of ...

View answer
Enable revisions for custom post type
Accepted answer
71 votes

When you register your CPT, you need to manually add support for revisions. Only title and editor are set as defaults. Check out the codex. So if you need to enable revisions, you need to add it like ...

View answer
Is There a Difference Between Taxonomies and Categories?
Accepted answer
67 votes

Taxonomies, as previously described are a collective noun for the following category post_tag post_format link_category custom taxonomy The first four are built-in taxonomies, while custom ...

View answer
How to limit the number of posts that WP_Query gets?
Accepted answer
65 votes

I think that now I understand what you are trying to do. When you run a custom query with WP_Query and set the limit to get only 5 posts per page, only 5 posts will be retrieved by the query and that ...

View answer
Custom post type single page returns 404 error
Accepted answer
54 votes

You should set your publicly_queryable argument to true when registering your custom post type. TAKE NOTE: Add flush_rewrite_rules(), refresh the page once or twice and REMOVE IT IMMEDIATELY. You ...

View answer
How to customize the_archive_title()?
Accepted answer
51 votes

If you look at the source code of get_the_archive_title(), you will see that there is a filter supplied, called get_the_archive_title, through which you can filter the output from the function. You ...

View answer
Get page id by template
Accepted answer
48 votes

When a page is created, the assigned template to that page is saved as custom post meta in the same way as custom fields. The meta_key is _wp_page_template and the meta_value will be the page template ...

View answer
Some doubts about how the main query and the custom query works in this custom theme?
Accepted answer
35 votes

Your actual question is basically when to run a custom query and when to make use of the main query. Lets break it down in three parts PART ONE When to run a custom query (This is not a definitive ...

View answer
How do I retrieve the slug of the current page?
34 votes

EDIT 5 APRIL 2016 After digging for more reliability, I ended up doing this answer to the following post which leads to this edit: (Be sure to check it out) $GLOBALS['wp_the_query'] vs ...

View answer
$GLOBALS['wp_the_query'] vs global $wp_query
Accepted answer
33 votes

You have missed one, $GLOBALS['wp_query']. For all purposes, $GLOBALS['wp_query'] === $wp_query. $GLOBALS['wp_query'] is however better for readability and should be used instead of $wp_query, BUT, ...

View answer
Wordpress plugin shortcode not working
33 votes

There are a couple of things to check here One: Is your plugin activated. Two: Is your shortcode in your main plugin file. If that code is in another file inside your plugin, did you make sure to ...

View answer
Custom post meta field effect on the performance on the post
Accepted answer
31 votes

To answer this, I have gone and done some tests on this, and the results was actually mind blowing. Here is my test To this yourself, set yourself up with a test page. Just simply copy page.php, ...

View answer
Can wp_query return posts meta in a single request?
Accepted answer
25 votes

By default, WP_Query returns the standard WP_Post objects for the posts being queried. I believe with some clever rewrite and use of the filters given in WP_Query you can add objects to the returned ...

View answer
get_terms - only top level
Accepted answer
24 votes

Your code is correct, well almost correct. On first view, I must confess, I missed it too. You have two syntax errors in your code. If you look closely, 'parent ' and 'parent' is not the same. You ...

View answer
Remove more or [...] text from short post
24 votes

The codex is your friend and should be your first stop :-) The [...] is added by the_excerpt(). There is a filter supplied called the excerpt_more filter that is specifically included to customize ...

View answer
Have different number of posts on first page
Accepted answer
22 votes

EDIT - ANSWER REVISITED I've being working on another solution which is actually better the original answer. This does not involve any custom query and I think for all purposes my original answer can ...

View answer
Pagination returns 404 after page 20
Accepted answer
20 votes

What you are experiencing is quite normal and expected. This is one of the big reasons I always hammer on this point, never use custom queries to replace the main query on the home page or any type of ...

View answer
Difference between meta keys with _ and without _
Accepted answer
20 votes

The underscore prefix are private, these meta fields will be hidden and will not be shown as custom fields in the post backend screens. Those meta fields without the underscore prefix are public ...

View answer
Why does my child theme CSS get called twice?
Accepted answer
20 votes

This post is linked from this post which I have now updated with the changes in this post Thank you for bringing up this issue. I have quickly tested the scenario and the child style is actually ...

View answer
Get all categories and posts in those categories
19 votes

EDIT REVISIT NO 2 I have never touched the Transient API, until today when I saw @MikeSchinkel answer in this post. This inspired me to revisit this post once again. After some testing, I came up ...

View answer
Wordpress get_posts by category
Accepted answer
18 votes

In all probability you are using a custom taxonomy, and not the build-in category taxonomy. If this is the case, then the category parameters won't work. You will need a tax_query to query posts from ...

View answer
apply_filters('the_content', $content) vs do_shortcode($content)
17 votes

QUESTION AND ANSWER REVISITED There are sometimes these questions that nags you and hunts you down later in life again, and this is one such question. This question had me thinking about an ...

View answer
Using pre_get_posts on true pages and static front pages
Accepted answer
14 votes

I finally got it working, but not with the code in my question. I totally scrapped that whole idea and restarted going in a new direction. NOTE: If anyone is ever able to sort out the issues in my ...

View answer
Paginate links with "ugly" and "pretty" permalinks?
Accepted answer
14 votes

EDIT - WORDPRESS 4.4.1 BUG Please take note that there is a bug in WordPress 4.4.1 (I'm not sure if this bug also influence WordPress 4.4, but according to the bug report, it does not) which fails ...

View answer
Should we use plugins that aren't available from the official WordPress site?
Accepted answer
14 votes

There is no definite answer as each plugin, whether available in a repo or not, should be handled on its own merit. Also, who says that that plugin caused your site to get hacked, it might have being ...

View answer
Is there a way of increasing the speed of this query?
Accepted answer
14 votes

We can do quite a lot to improve performance of your code. Lets set some benchmarks first BENCH MARKS I'm testing this with a category taxonomy term which has 9 posts and the post_tag taxonomy ...

View answer
Return only Count from a wp_query request?
Accepted answer
14 votes

There is no build in function to achieve what you want, at least not for complicated meta queries like this. If you need to use build in functions for this, the best will be to make use of WP_Query. ...

View answer
What is singular.php?
13 votes

singular.php is basically an extra fallback for all post types, regardless if built-in or custom. It comes in straight after single.php and page.php, so you can omit the latter two templates and just ...

View answer
1
2 3 4 5
45