WP_Query tax_query – Show results if child has parent X

If I’m understanding you correctly get_term_children does what you want. $term_id = 2; $tax_name=”locations”; $term_child = get_term_children( $term_id, $tax_name ); Another possibility would be using get_categories, it has an child_of, taxonomy and depth parameter – the documentation on wp_list_categories, which offers pretty much the same functionality, is better.

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

Unable to paginate a custom page query

The problem was in the same name for category slug “categories” and the same for the custom page that was holding all categories with the same name “categories”. I have solved that by changing categories slug (in permalinks settings) to singular “category” and I have left custom page as plural “categories”. If somebody know about … Read more

specific post is not excluded from the loop

You’re just off by one letter it seems. post__not_in => array(118) Post & Page Parameters You can also try adding an if statement, such as: if($post->ID != 118) : … run rest of code Though not optimal, without seeing the rest of your template I can’t be certain. Additional Edit: <?php $loop = new WP_Query(array( … Read more

How to properly use Categories with Custom Post Types

Your get_posts call needs a posts_per_page argument if you want more than whatever the default number per page is. Use -1 to retrieve all matching posts. $featured_posts = get_posts( array( ‘post_type’ => array( ‘post’, ‘books’, ‘cds’, ‘maps’ ), ‘category’ => get_theme_option(‘featured_posts_category’), ‘posts_per_page’ => -1 ) );

Meta query relation ‘OR’ not working as expected

You are looking for this, most probably. Note: meta query support a compare method what is ‘IN’, which means any of the value. Like this – if( isset($_GET[‘H_property_type’]) ){ // you don’t need relation for this // if(count($_GET[‘H_property_type’]) > 1){ // $args[‘meta_query’][‘relation’] = ‘OR’; // } // if $_GET[‘H_property_type’] is an array // foreach ($_GET[‘H_property_type’] … Read more

Return category posts with WP_Query

By default WP_Query will return only the post post type. To retrieve other post types, you need to add a post_type argument. Using any will return results from all public, registered post types. $my_query = new WP_Query( array( ‘cat’ => 1, ‘post_type’ => ‘any’ ) ); var_dump($my_query->request); // debug; allows you to see the SQL … Read more