- Create a must-use plugin.
- Put it in
<docroot>/wp-content/mu-plugins/selective-posts.php
-
Following should be the code in
selective-posts.php
to filter specific posts.function golfclubs_tag( $query ) { if ( $_SERVER['HTTP_HOST'] === 'www.golfclubreviewdomain.com' ) { $query->set( 'tag', 'golfclubs' ); } } add_action( 'pre_get_posts', 'golfclubs_tag' );
This way it would filter all the queries across the site for specific domain and it would filter the posts with specific tag.
If you want to add another tag in the query, you can edit the above code as follows:
function golfclubs_tag( $query ) {
if ( $_SERVER['HTTP_HOST'] === 'www.golfclubreviewdomain.com' ) {
$query->set( 'tag', 'golfclubs,general' );
}
}
add_action( 'pre_get_posts', 'golfclubs_tag' );
Related Posts:
- Must Use Plugin Causing Query Error
- List posts that don’t have a specific tag?
- Limit tags shown in post
- View tag description on page
- Display product attributes for current product
- How can I fetch loop of post titles via AJAX?
- Inject post (from specific category) between posts in Loop
- Edit tag cloud widget number
- get product attributes for current product and store it in a variable
- Installing wp3.2.1 on IIS; getting empty sessions
- Want to separate sections of posts. Can you restart loop?
- MySQL query performed 4 times inside loop
- Specific Loop For 2 Within Each
- Two posts in same div – WP loop
- Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin – Adding to “Thoughts” Theme
- Woocommerce, recognize the loop of related products
- Custom Loop through category menu to include sub categories
- How do I display the function the_content in this loop?
- Facebook “like” open graph meta in header.php
- Custom excerpt function re-factoring
- How can I show the post thumbnail from the most recent of a certain post type, in widget?
- Adding country tags automatically
- ACF page while loop breaks footer while loop
- Using foreach loop breaks
- Split loop into two columns, how to favor one side over the other
- Dynamic Stylesheet loads but doesn’t finish
- Filter Select results based on selection
- Loop with slider (slider not loading)
- How to hide all child pages with post_query?
- How to sort posts based on the value (number) of a post’s metadata?
- Displaying Woocommerce Product Category in WordPress
- How can I add extra word in permalink when someone click download button?
- Increase offset while looping
- Woocommerce : Can’t get product info in loop
- remove post that has no content
- Can we count the WordPress Loop
- Get post id within comments loop
- Syntax error when I try to insert my loop into an unordered list? [closed]
- Need to put a script above tag in header.php – WP 5.7.1
- Custom Pagination is Broken
- Trying to prepend a Hashtag symbol to the_tags links [closed]
- How to overwrite orderby with add_query_var
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- Last class on last headline?
- get_the_ID() in the footer returns wrong value
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- How to get current post category details inside “loop”?
- WP_Query multiple post results
- Convert Featured products loop into Recent products loop?
- Echoing a CSS class based on category of post in a list
- Posts are not looping through correctly
- Querying for specific tags
- Create Div Wrapper On 3rd Iteration Or When Query Loop Items Run Out
- Php code error in wordpress if else statements [closed]
- pagination broken – clicking next displays “page not found”
- Add class to every other posts using get_posts
- Wp Query : Order by distance lat,lon
- remove specificly the last tag in all posts
- How to Add a cutsom slug to my custom author role
- How do I get pagination for get_posts() in WordPress or do I have to rewrite the whole code?
- Give ID to divs inside the loop
- Display articles with a different template in the home page | Solved |
- How to output the taxonomies that are assigned to each custom post?
- Check if current post in loop is last on current page
- Looping through dummy posts and showing them in the main index.php
- Custom Loop.php having a loop inside a loop
- ACF – Get ID of relationship field in flexible content
- How do I create a WP endpoint that retrieves all custom post types that have a tag?
- WordPress Ajax filter: Create two loops for different output styles?
- How to display sticky post always at the top (before regular post) in wordpress?
- adding or removing endforeach; throws error!
- Return to the beginning of the results of a for loop
- How to count posts posts if they are in a separate content page?
- Adding PHP to an if else loop
- Thumbnail wouldn’t scale to size properly
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- Filter loop by ‘price’ with meta_query
- Problems with the WordPress loop [closed]
- Add div after every 4 posts then every 2 posts for a responsive loop
- Get a list of tags present in a paged front page
- Notify admin (by email) if post added with specific tag
- WordPress while loop with aphabetic counting like one, two, three
- Retrieving specific images from Media Library
- Add post class in custom loop (WP_QUERY)
- Custom Taxonomy Link Text Echo Name Not Slug
- Adding unique marketing messages between certain products whilst using isotope/Infinite Scroll
- A Space being added to url generated by custom plugin
- I want my wordpress loop to only display posts of the standard format
- Automatically create a loop for post ID
- Using tag to output text in Genesis?
- Is there a way to randomize and connect a background and header image?
- why is this content-template not showing any of my blog-entries?
- the_post_thumbnail unless video id is added
- Trying to display ads on only a third of posts in a loop. Keep getting Error 500?
- How to call the_author_meta and make it work?
- WordPress post pagination on custom template not working
- Implement “No related posts for this entry” into the loop?
- Excerpt all post content Content Same Size without word cutting off
- Options.php loop won’t show!
- How do I exclude the current post from the upcoming post query