function wp() does not use meta_query?
Don’t call wp() directly. You should instead use a pre_get_posts action hook.
Don’t call wp() directly. You should instead use a pre_get_posts action hook.
Say you have 10 pages of posts, 10 posts per page. When you load the first page and the transient doesn’t yet exist, your query loads the first page (10 posts) and you put that in a transient. Now you navigate to page 2, and check if the transient exists. it does (you set it … Read more
Typically, you would be echoing content from an action hook, rather than returning it, and from I can find about this Woo Theme hook that looks to be the case here too. Try echo $output; instead of return $output; See: Clarification on filters and hooks Difference Between Filter and Action Hooks?
And here is the correct implementation: Register the category taxonomy for the page post-type: function wpse121285_add_category_to_pages() { register_taxonomy_for_object_type(‘category’, ‘page’); } add_action( ‘admin_init’, ‘wpse121285_add_category_to_pages’ ); Add the appropriate category term to the desired page. Then modify the default $wp_query object at pre_get_posts: function wpse121285_pre_get_posts( $query ) { // Main query for the blog posts index // … Read more
If I understood correctly, you need something like the following: $args = array( ‘post_type’ => ‘book’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘subject’, ‘meta_value’ => YOUR_SUBJECT_PAGE_TITLE, ); $books = new WP_Query($args); Is this what you’re trying to achieve? Also, please have a look at WP_Query.
A quick count shows me that you have 18 columns there, but only 16 types in the type array. Double check your types.
Regarding your first problem, because $args is an PHP: array you could do something like this: Code: $args = array( ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘custom_post_type’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => ‘150’ ); if ( $catArr ) { $args[‘tax_query’] = array( array( ‘taxonomy’ => ‘tax_type’, ‘field’ => ‘id’, ‘terms’ => $catArr ) … Read more
I can only assume that there is filter running on the category page that is overwriting your post type. Try adding ‘suppress_filters’=>true to your query arguments, but that only works for some filters not all. I suspect it will not work in this case. Or find the filter that is altering the query and modify … Read more
use caching plugins, that is why they exist – to offload work from the DB. If you don’t want to do full page caching and you know that the resulting HTML do not change much you can use transients to store the result for something like an hour before recalculating it.
You can use this query instead to select comments count grouped by user id. SELECT user_id, COUNT( * ) AS total FROM wp_comments WHERE DATE(comment_date) = CURDATE() AND user_id <> 0 GROUP BY user_id by the way, in your where variable you should use $wpdb->prepare() to assign values with variables ( if you are going … Read more