WP_Query – Exclude Posts

You’ll need a second tax query for posts not in the child categories of the given category. To do that you’ll need to get the IDs of the children. This is possible with get_term_children(): $args = [ ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => $post_number + 1, ‘paged’ => ( get_query_var( ‘paged’ ) ) … Read more

1/3 of posts different class

The explanation is in the comments: <?php … if ( $query->have_posts() ) : //number of small ones needed = a third of total number of posts $numsmallneeded = round($query->post_count / 3); … while ( $query->have_posts() ) : $query->the_post(); //if no more small sizes are needed, use big if ( !$numsmallneeded ) $size = 1; //if … Read more

Tax query AND/OR meta query [duplicate]

It’s not possible without a more custom query/filter. I have achieved it with a filter (code taken from this guy on this gist – https://gist.github.com/elvismdev/61f8509eff8abcc21ef84154b74fbf56) function f1_egpaf_meta_or_tax( $where, \WP_Query $q ) { // Get query vars. $tax_args = isset( $q->query_vars[‘tax_query’] ) ? $q->query_vars[‘tax_query’] : null; $meta_args = isset( $q->query_vars[‘meta_query’] ) ? $q->query_vars[‘meta_query’] : null; $meta_or_tax … Read more

Having trouble with WooCommerce Storefront child theme single.php “related posts” modification [closed]

The reason you’re getting a white screen is you never defined “$string”. You only concatenated it. In the future you can find your errors when creating functions by turning wp_debug to true in your wp_config.php file. Here is code that should work: function new_function() { //Arguments: posts, in classifieds category, that are published, and from … Read more