Trying to use WP_Query to display a custom post type

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?

Include one page/post into query which is already returning posts

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

Using WHERE on a WP_Query

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.

wp query meta value is not null

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

Echo User Name from User with most comments of today?

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