Filter by one custom field, order by another?

You could use the query to filter the content as you intended by using the ‘meta_query’ with filtering options, and for the order part, just add/modify the following parameters: ‘orderby’ => ‘meta_value’ ‘meta_key’ => ‘location_level1_value’ ‘order’ => ‘ASC’ $wp_query = new WP_Query( array ( ‘post_type’ => ‘listing’, ‘posts_per_page’ => ‘9’, ‘post_status’ => ‘publish’, ‘meta_query’ => … Read more

WP_Query leaking absurd amounts of memory

Excellent responses on WP Hackers: http://lists.automattic.com/pipermail/wp-hackers/2012-June/043213.html What you’re doing with that query, is loading EVERY matching post into memory, including the full post contents. As you can imagine, this is probably quite a lot of items. You can pass ‘fields’ => ‘ids’ into WP_Query to simply return a list of matching post_ids instead, which should … Read more

Multiple WP_Query loops with Pagination

Yes, it can be done. The key is to make the format parameter different for the two queries: <!– Cats –> <div class=”animals”> <? $paged1 = isset( $_GET[‘paged1’] ) ? (int) $_GET[‘paged1’] : 1; $paged2 = isset( $_GET[‘paged2’] ) ? (int) $_GET[‘paged2’] : 1; // Custom Loop with Pagination 1 // http://codex.wordpress.org/Class_Reference/WP_Query#Usage $args1 = array( … Read more

Best Practice for PHP

That’s question is only relevant, because WordPress use a mix from a coding language and layout language. If you would use a template language, syntax, than is this topic not relevant. But to your question. If you use your example source for a Theme, much more layout language like html, then I prefer the first … Read more

tech