Can ordering post list by meta_value cause performance issue?

meta_query & tax_query behavior When you’re defining a meta/tax_query and make use of the new array style argument list for multiple sets of term or custom field keys, then your query might look close to the following array( ‘tax_query’ => array( ‘relation’ => ‘OR’, array(‘taxonomy’ => ‘tax1’, ‘field’ => ‘slug’, ‘terms’ => ‘term1’), array(‘taxonomy’ => … Read more

Pagination on custom query

Add this to your query: ‘paged’ => get_query_var(‘paged’) Like so: $args = array( ‘post_type’ => ‘species’, ‘meta_query’ => $meta_query, ‘tax_query’ => $tax_query, ‘paged’ => get_query_var(‘paged’) ); Should do the trick.. Using Wp-pageNavi? dont forget to add the wp-pagenavi tag just after the loop ends <div class=”navigation”><?php wp_pagenavi(); ?></div> . Hope This Helps 😉 Cheers, Sagive.

meta_value_num sort glitch

You want natural order sorting, Example; $val = array(5.1, 5.11, 5.12, 5.2, 5.21); natsort($val); foreach ($val as $key => $val) { echo $val.”<br>”; } Produces: 5.1 5.2 5.11 5.12 5.21 Where as; $val = array(5.1, 5.11, 5.12, 5.2, 5.21); asort($val); foreach ($val as $key => $val) { echo $val.”<br>”; } Produces: 5.1 5.11 5.12 5.2 … Read more

Include a specific post to the query_posts and remove it if it is already in the returned list

Okay so I tried to read your code, and failed, and reformatted it as it’s currently unreadable, and any errors are obscured by this unreadability. I cannot stress the importance of indenting correctly and following a standardised formatting for making your life infinitely easier: <?php $featured_class=”et_cycle”; $tag = ‘ul’; $attr=”class”; if($responsive){ $featured_class=”flexslider” . $featured_auto_class; $tag … Read more

Order by meta_key with two meta_queries

You can do this using WP_Query since 3.1 with a meta_query. $args = array( ‘meta_key’ => ‘_count-views_all’, ‘orderby’ => ‘meta_value_num’, ‘order’ => $sortOrder, ‘posts_per_page’ => 9, ‘paged’ => $paged, ‘meta_query’ => array( ‘relation’ => ‘OR’ array( ‘key’ => ‘contributorid1’, ‘value’ => $id, ‘compare’ => ‘=’ ), array( ‘key’ => ‘contributorid2’, ‘value’ => $id, ‘compare’ => … Read more

Exclude category from loop not working

Don’t use query_posts(). Use pre_get_posts instead: function wpse82745_filter_pre_get_posts( $query ) { // Only modify the main loop, // and only in the blog posts index if ( is_home() && $query->is_main_query() ) { $query->set( ‘category__not_in’, array( ’13’ ) ); } } add_action( ‘pre_get_post’, ‘wpse82745_filter_pre_get_posts’ ); This callback will exclude category 13 from the main loop in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)