Exclude latest post from WP_Query taxonomy term loop

wp_query has the offset parameter which you can use to skip posts, e.g. $args = array( ‘post_type’ => ‘video’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘tax-video’, ‘field’ => ‘slug’, ‘terms’ => ‘t-o-t-w’, ), ), ‘posts_per_page’ => ‘8’, ‘offset’ => 1, // excludes the first post in the query ); you may just be over thinking … Read more

How to exclude a category name from showing?

The function get_the_category is returning you an array of objects (see codex for more info), so if the post has more than one term assigned, then you are just outputting the first one. So I think that doing a foreach loop will solve your problem: foreach ($category as $cat) { if ($cat->slug != ‘featured’) { … Read more

Query only displays one page_id

The p parameter accepts a single integer value, not a string or array of integers. You would want to use the post__in parameter which allows for an array of post id’s. Just a few notes here: You will need to check if you actually have a valid array of post ID’s before passing it to … Read more

Dividing the loop to style post differently

You don’t need to alter the code for different formatting, you can simply use the :first-child pseudoclass in css. The foreach loop will, presumably, generate similar blocks of code, structured like this: <div class=”all-my-posts”> <article class=”my-slider-post”> … </article> <article ..> </article> … </div> Now you can simply addres the first <article> block with css like … Read more

WP Query – filtering terms with regex

This is untested, but give it a go. First get a list of the term names in the taxonomy. Then filter the returned array of names against your regex. Then use that filtered array of names for your WP query. // assumes these assignments: // // $taxonomy – the taxonomy name you are querying against … Read more

WP_Query with one category in args shows other categories

Tried your code in a simple page and work correctly. Have you set the “Blog” page as posts page within the “Settings > Reading”? Because in this case the correct code that the cms will load is home.php or index.php according to the template hierarchy https://developer.wordpress.org/files/2014/10/template-hierarchy.png