Why does “Blog pages show at most” interfere with my custom wp_query?
see: http://scribu.net/wordpress/wp-pagenavi/wpn-2-74.html
see: http://scribu.net/wordpress/wp-pagenavi/wpn-2-74.html
is_search() is only true if the main query is for the search results. When you create your own query with new WP_Query, you’re not using the main query. Additionally, AJAX requests do not even have a main query, so functions like is_search(), is_archive() etc. do not work. If you want to check if a specific … Read more
The default arguments for get_posts() function include ‘numberposts’ => 5. So if you’re querying for a search term that returns more than five (5) results the second query will return a maximum value of 5 unless you pass ‘s=computer&numberposts=-1′ as your query string. The WP_Query object doesn’t have a ‘numberposts’ default, although it is affected … Read more
As of writing, there is no meta query compare value that can do what you’re trying to do, which is basically “where <updated_at meta> > <build_ran_at meta>“. But there are two options that you can choose from as an alternative to using the meta_query arg: Use a raw SQL to retrieve just the IDs of … Read more
To order by event-end date or start date, your write separate function and call them as per requirement. For example if user clicks on order by start then start function should be called. switch($orderby){ case: ‘event-start’: # your code /* $query[‘meta_key’] = ‘event_start_date’; $query[‘orderby’] = ‘event_start_date’; */ break; case ‘event-end’: #your code /* $query[‘meta_key’] = … Read more
Because this is very similar to How to reduce the database query-es I will then give you an outline of a possible solution: You have four similar loops with 1) 1 post && offset=0 2) 4 posts && offset=1 3) 5 posts && offset=1 4) 6 posts && offset=1 so your main query will be … Read more
Try this: add_filter(‘posts_where’, ‘unquote_numeric_meta_value’, 10, 2); function unquote_numeric_meta_value($where, $args) { $value = isset($args->query_vars[‘meta_value’]) ? $args->query_vars[‘meta_value’] : false; if(is_numeric($value)) $where = str_replace(“‘{$value}'”, $value, $where); return $where; }
When you are constructing the $output variable, you need to consider get_the_post_thumbnail() get_the_excerpt() get_the_content() get_permalink() that return the values instead of the_post_thumbnail() the_excerpt() the_content() the_permalink() that echo the values.
I doubt using get_posts() vs WP_Query() would make any meaningful/noticeable difference in CPU load. Ultimately, get_posts() is just a wrapper for WP_Query(), anyway: $get_posts = new WP_Query; return $get_posts->query($r); You would be better served by looking at the efficiency of the queries themselves; but to provide specific assistance there, we would need to see each … Read more
When creating an internal rewrite rule, $1 should instead be $matches[1].