Since you’re working with the tag archive index page query, this really won’t be all that difficult. You simply need to filter the query parameters at pre_get_posts
, using your criteria.
For example:
function wpse137627_pre_get_posts( $query ) {
// If this is the tag archive index,
// and is the main query
if ( is_tag() && $query->is_main_query() ) {
// Limit the query to the specified category
// Change '123' (int) to the appropriate category ID
$query->set( 'cat', 123 );
}
}
add_action( 'pre_get_posts', 'wpse137627_pre_get_posts' );
You can also pass the category slug, using $query->set( 'category_name', 'cat-slug' )
.
Related Posts:
- how to add tags to post in the Loop?
- Should we trust the post globals?
- How to know if get_posts() failed?
- Duplicate posts
- Looping through posts per category gives same posts for each category
- How to show posts rank based on custom field value
- How do I create Comma Separated list of attached image ids?
- How to display post tags
- How can I get all posts data from within a paginated search result?
- Does an action fire when adding a tag via the “Tags” meta box?
- Check if post exists
- Filter Posts By Tag
- Only display posts after current date
- WP Query related posts by current page Tag ID
- Add Post Tags to Body Class
- How to prevent WordPress from updating the modified time?
- WP Query – duplicated posts once including tags in search results
- wp_tag_cloud() and the_taxonomies() work but not the_tag()
- Prepend or add an Image to the content of a Post
- WP_Query Authors OR Categories
- Display posts with tag that matches current post title
- Using permalinks, category slugs, and tag slugs
- Print all the tags from a custom post type Please
- Add multiple tags to multiple posts
- get query() without post content?
- WP_Query: Mixing category__in and tag__in together
- Exclude the first ‘n’ number of posts of a tag from home page?
- How can I hide tags on a child-category page, if that tag has not been used?
- posts_per_page option limits the number of Gallery items
- How to get a post’s content? [closed]
- How Do I Get My Post Tags to Alphabetize?
- Dynamically switch template on click
- Get all custom post types excepted some…
- Get all comments of author’s posts
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- Counter is skipping post when I still want it visible [closed]
- Display related post by tag name of current post
- Do not show children of a category
- How to remove specific tag from multiple posts?
- How to get all post_parents of a post?
- Run query_posts if SESSION is empty?
- Extracting relevant tags associated with that particular single post only
- See if a post has a specified tag
- How to get post with associated categories and tags names instead of ids with rest api?
- Changing Post Tag Color Based On Post Count
- How to give classname to post if post has no content?
- Exclude some posts from displaying in wp_query based on some condition
- How to retrieve certain number of images from a wordpress post?
- Removing all post tags except a given list
- How to convert query sql to shortcode in wordpress?
- How to compare post tags?
- Would a “hub” page work better as a page or a post?
- Some doubts about how the loop work (trying debugging it)
- Plotting posts on a graph
- Short link to read complete post
- Delete all Tag Links from Posts
- Adjust the order for returned posts
- get last post’s link with SQL query
- Trim posts from WP-Query?
- Trying to exclude custom posts based on date, while sorting by custom field
- How to Rearrange WordPress Tags list on frontend using Shortcode with specific order?
- Can I show category name in url for only one of my categories?
- Merge get_comments & get_posts into a single query
- Is there a way to categorize a list posts all at once?
- How to optimize posts query in wordpress
- Css and function issue on author archive page
- How to search through “post title” and “tags” using WP_Query?
- Need to display a Jan 1st post as the site’s front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc
- Top tags with minimum number of posts
- How to count posts in tags within time limit
- Why do I have categories with duplicate slugs?
- Exclude posts in home slider from sections
- I have two post types in the same query, how can I use CSS to select only one post type?
- Display all tags even if they are not assigned to a post
- getting custom post by tag
- Replace Tag Keyword With Link Within Post Content
- Bulk Post update_post_meta
- Numbering author posts in posts query
- How to run select query of post with category and tags?
- Query post for today, if no post get the previous one
- Custom Select Query pagination not working properly
- Sort / Filter Queries
- Hide Certain Tags on Single Post Page
- Display the latest post from some selected authors
- Advanced Post Display/Pagination/Ordering
- Continuous listing from a custom field
- Add tags to post before it’s created
- Displaying Results From Custom Taxonomy Query
- How to store post rating system data post independent?
- Get first comment link on the post itself
- How can I count articles retrieved by tags
- Should new posts already have tags?
- Make division in post_query?
- retrieve post slug by post_tags taxonomy
- Display one post randomly from category on home page
- WordPress More tag doesn’t work on Single post
- Display posts with id equal to relationship value
- Sort Posts Alphabetically Based on Specific Category (Divi)
- Get related posts matching most of the provided tags using WP_Query
- How to remove category and other tags from posts page