Order by value in serialized custom field
I would write a converter and separate all of these data once. There is just no way to build a really fast query against serialized data.
I would write a converter and separate all of these data once. There is just no way to build a really fast query against serialized data.
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
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.
You could do this by sorting on a calculated factor. Dividing the rating by the days gives a good starting point: rating/days = factor (e.g. 15/6 = 2.5 or 11/3 = 3.6) You can balance this to your needs by multiplicate the variables (rating and day) with any factor you like. There are to ways … Read more
Try using get_queried_object(): $term = get_queried_object(); echo $term->name; If you get nothing there, try this: print_r($wp_query); Everything you need is in the $wp_query global. Hope this helps you.
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
Yes, use caching. But even with caching you should rethink what you are actually doing because the cache for page/2 should change every time you publish a new post which might make caching pointless depending on the amount of traffic to that page. You should probably rethink what you are trying to achieve there, why … Read more
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
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
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