Sorting multiple custom post types without a meta key/value pair by sort order

What ended up working is adding the array key, “orderby” and adding menu_order: <?php // query for vidoes in the home page category $args = array( ‘post_type’ =>array(‘videos’, ‘podcasts’), ‘category_name’ => ‘Videos on Homepage’, ‘post_per_page’ => 4, ‘order’ => ‘DESC’, ‘orderby’ => ‘menu_order’, ); $loop = new WP_Query($args); // start loop for first set of … Read more

WP Query Returning All Posts

I think you’re confusing old meta parameters with new meta_query parameters. meta_key should be just key and meta_value should be just value. Refer to WP_Query in Codex for correct syntax. Also, print_r( $country_query ); will show you the actual SQL query being sent to the database and will show you where you’re going wrong.

reducing the amount of wp_query calls

Rather than querying for a single item and then querying again for 6 more excluding the first, you can just do a single query for 7 items and selectively output markup by checking which post you’re currently outputting in the loop via $your_query_object->current_post. You can also combine that with $your_query_object->rewind_posts() to run through the same … Read more

WP_Query() returns null when results exist!

The is_single function (used in your excerpt.php file) returns true only when the main query contains one single post. Since you’re calling get_template_part from an archives page, your query contains more than one post, so is_single returns false and your excerpt.php file bails. Remove the check for is_single and you should be good to go. … Read more

Use query->set or make new query?

If you can alter a query before it runs, then do so and save the database some work. You might be able to alter the query with query->set() and if not you can use the posts_where, posts_fields, etc filters. It is hard to say whether any of that is best for you without more information. … Read more

Comparing dates in custom field

Your date format is in the wrong order. Think of it from a strictly numerical perspective- 11222012 > 1032013 Dates should follow the MySQL date format in descending units- yyyy-mm-dd

How do I Use Multiple Loops with WP_Query?

As Toscho mentionned above, you didn’t close your if and while. When in doubt, indent your codes to avoid confusion. $my_query = new WP_Query( $args ); if ($my_query->have_posts()) : while($my_query->have_posts()) : $my_query->the_post(); endwhile; endif; wp_reset_postdata(); /* The 2nd Query (without global var) */ $query2 = new WP_Query( $args2 ); // The 2nd Loop if ($query2->have_posts()) … Read more