[Solved] How to change a custom query into a standard loop?

In order to be able to use template tags, you have to do two things after getting your custom select query: You have to declare the global $post variable. You have to call the setup_postdata($post) function to populate the variables. So, my code had to be changed like so: $results = $wpdb->get_results($wp_query->request, OBJECT); global $post; … Read more

[Solved] Query not returning CPT posts

I had a similar problem and posted the solution here: http://wordpress.org/support/topic/role-scoper-updating-query_posts query_posts causes the main WP_Query to be discarded. That may or may not be the behavior you want. If no, you need to update WP_Query, then you could update your functions.php file to include a register filter that displays your content types as part … Read more

[Solved] When to use WP_query(), query_posts() and pre_get_posts

You are right to say: Never use query_posts anymore pre_get_posts pre_get_posts is a filter, for altering any query. It is most often used to alter only the ‘main query’: add_action(‘pre_get_posts’,’wpse50761_alter_query’); function wpse50761_alter_query($query){ if( $query->is_main_query() ){ //Do something to main query } } (I would also check that is_admin() returns false – though this may be … Read more

[Solved] When should you use WP_Query vs query_posts() vs get_posts()?

query_posts() is overly simplistic and a problematic way to modify the main query of a page by replacing it with new instance of the query. It is inefficient (re-runs SQL queries) and will outright fail in some circumstances (especially often when dealing with posts pagination). Any modern WP code should use more reliable methods, like … Read more