Ignore post by meta value in the main query

We can try the following alternative way: Remove the two posts we select via our custom query from the main query via the pre_get_posts action Return the two posts on top of page one via the the_posts filter Lets look at possible code: add_action( ‘pre_get_posts’, function ( $q ) { remove_filter( current_filter(), __FUNCTION__ ); if … Read more

Exclude first 2 posts with meta_key from loop

First point is that you should NOT use query_posts() for custom queries. The better approach is to use the WP_Query class. More info in the WP docs and here. This example will display your 2 featured posts and then exclude them in the second query. // We will push the ID of your featured posts … Read more

Separate Posts and Custom Post Type in Custom Taxonomy archive template

Going from memory this should work for posts <?php $query1 = new WP_Query( array( “post_type” => “post”, “tag” => $term->slug) ); ?> The first query will only return posts that have been tagged [TEAMNAME] (as far as I can remember custom taxonomies can show up as tags on a post). This should work for teams … Read more

get_option issues

I have found the solution on another forum but if someone has the same problem than me here’s the solution : For theme options modified through the $wp_customize, use get_theme_mod() instead of get_option() to retrieve the value.