WP_Query (list) posts according to author’s custom field
WP_Query (list) posts according to author’s custom field
WP_Query (list) posts according to author’s custom field
Custom Pagination in Shortcode with WP_Query
You can use meta_query to combine multiple queries using either AND or OR relation. Granted, it does get a bit complex in this case, but because you can nest multiple queries, you can still achieve it. This is covered in the WP_Meta_Query documentation and also to an extent in the WP_Query docs. Here’s what I … Read more
Display most popular in the past two days
Order ascending is ignored in meta query?
Search for “2nd” also returns “22nd” in wp_query
I managed to do it. I used the following query parameter: ‘tax_query’ => array( array(‘taxonomy’ => ‘wpccategories’, ‘field’ => ‘slug’, ‘terms’ => $termz ) ) With $termz being: $termz = wp_get_object_terms($id, ‘wpccategories’, array(“fields” => “slugs”)); The problem I struggled with was that I needed to use singular ‘field’with singular ‘slug’ in the tax_query (I knew … Read more
The is_category function checks the queried object. Since this is in pre_get_posts, the query has not happened yet. Check the other parameters to find if the query is going to be for cat 5, not if the results are for cat 5. Try ->get(‘cat’).
I think you can simply use: post_class( 0 === $featured_posts->current_post ? ‘first’ : ” ); to add the first class directly within your template code, instead of applying the post_class filter.
You can just run through the loop and set a flag: if ( $query->have_posts() ) : $any_in_cat = false; while ( $query->have_posts() ) : $query->the_post(); if ( in_category( ‘first-major’ ) ) : $any_in_cat = true; endif; endwhile; $query->rewind_posts(); /* if $any_in_cat == true at this point then at least one of the posts has the … Read more