Using wp_list_pages() after calling query_posts()

This is for future askers, Whenever you use query_posts or custom wp_query you should add wp_reset_query(); after your loop or when you are done processing your posts. This little line of code will help in solving pagination issues or in your case rest the global $post the original as before your query.

Limiting posts_join, where, etc to a specific WP_Query object?

The most reliable way is to define your own query var and then check it: $my_query = new WP_Query( array( … ‘context’ => ‘my_query’ ) ); Then, from your callback: function alter_post_clauses( $clauses, $wp_query ) { if ( ‘my_query’ == $wp_query->get( ‘context’ ) ) { // do stuff } return $clauses; } add_filter( ‘posts_clauses’, ‘alter_post_clauses’, … Read more

WordPress posts for multiple years

You should use a date range instead by filtering posts_where: function wpse_43397_where($where=””){ $where .= ” AND post_date >= ‘2008-01-01’ AND post_date < ‘2010-12-31′”; return $where; } add_filter(‘posts_where’, ‘wpse_43397_where’); $my_query = new WP_Query($args); remove_filter(‘posts_where’, ‘wpse_43397_where’);

cannot override post_types in WP_Query()

First of all,while( have_posts()): should be while( $ml_featured->have_posts()): And secondly, in your pre_get_posts callback you check: false == $query->query_vars[‘suppress_filters’] But this returns true for every WP_Query query and any get_posts query where ‘supress_filters’ is explicitly set to false. If you want to check if the query is the ‘main’ query (i.e. query associated with the … Read more

Category ‘pad_counts’ & ‘parent’ conflict

This is potentially a bug* – but it doesn’t seem like it is the same one you have linked to. The problem lies in the get_terms function. Specifically here: http://core.trac.wordpress.org/browser/trunk/wp-includes/taxonomy.php#L1397 The array of terms (which when parent=0, are are just the top level terms) gets passed to _pad_term_counts which says: Add count of children to … Read more

Does wp track views for posts?

WordPress does not maintain post view count by default. But you may find the following post helpful. Does wordpress have a post hit counter? You may also have a look on the WP-PostViews plugin. Many thanks.