Tags don’t create duplicate posts, so the likelihood of them hurting your SEO by appearing in a sitemap are slim.
You can add a filter to the return of the taxonomies sitemap to remove tags. This is just a quick attempt I threw together. I haven’t tested it but it should provide a basis to work from at the very least.
function remove_low_tags($taxonomies) {
//create a new array of tags with count above 2
array $allowed_tags;
//loop through current array of tags and add them to $allowed_tags if they are > 2
foreach ($taxonomies as $tags) {
if (count($tags) > 2) {
$allowed_tags[] = $tags;
}
}
return $allowed_tags;
}
add_filter('wp_sitemaps_taxonomies', 'remove_low_tags');
Related Posts:
- Can’t seem to get an else statement correct? [closed]
- Posts with at least 3 tags of a list of tags
- How to force a query conditional?
- Better way to get tag stats?
- Given a WP_Query, how can I get a list of tags?
- Executing Queries in tag.php
- How to order posts tag by tag?
- post_type is ignored by WP_Query when ‘tag’ argument is included
- WP Rest API v2 return posts with specific tag
- Loop through all tags & output posts in alphabetical list
- Order posts by tags count?
- How to get any tag ID
- Get all posts without tags
- WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)
- Targeting specific pages in the loop
- How to exclude products by tag from woocommerce shop page?
- Pagination problem after WP_Query with tag filtering
- How to check if a post “does not have term” in conditional statement?
- Query post from all category with same tag on 1 pages
- reducing the amount of wp_query calls
- WordPress Related Post by tags in Single.php
- How to build a WP_Query using mulitple tags and using AND or OR operator between them
- Include tags in WP_Query
- Search for multiple tags?
- Display posts from only one post form in custom query and exclude in main query
- Set conditional on template based on referring page slug
- How can I make WP_Query get posts that have a tag but also have random other tags?
- Cluster WooCommerce products in each Category Archive by Tags assigned to products
- Display tags with random thumbnail from selection of posts with that tag
- Query posts intersecting tags and categories
- Combining categories (Query posts with multiple taxonomy terms)
- Inserting HTML to close and open divs in WP_Query loops
- Order by most used tag
- WP Query with multiple tags by get the tags
- Is_single() conditional tag returns null in query
- WP_Query and is_page_template() conditional
- Show a 404 error page if Public query variable’s value doesn’t exist?
- Query Posts by Tag and exclude
- For what queries is conditional tags informative?
- Get posts that do not have the same tags as current
- Should $query-> be used with conditional tags?
- exclude product with available tag
- WP_Query by keyword OR post tag
- Display posts by tag
- Creating attachments archive in tags and categories
- Get posts with no tags?
- ajax wp_query conditional tags not working
- Filter products on category AND tag
- Only show tag with the same id as the post
- Get posts that match defined arrays of tags
- Order posts by tags count?
- Fix wp_term_relationships slow query in get_posts
- getting posts by tags
- Search with WP_Query, but ignore href URLs in anchor tags?
- Show posts from categories instead of tags
- post_type not working when tag__in is present?
- Related Post by Tags Code
- Exclude all tagged posts from WP_Query loop
- I cannot get tax_query in get_posts() to work with custom taxonomy
- WordPress custom query by archive title
- How to create page that lists tags by initial letter?
- How to make a wordpress loop file that displays posts based on certain conditions
- Random posts in WP_Query when searching by tag
- Issue attempting a wp_query_posts with tags
- Conditionals in WP_Query
- Limit Tags display and ad Drop Down Menu
- Get posts that were most recently tagged
- Way to include posts both with & without certain meta_key in args for wp_query?
- Calling a wp_query $posts causes a 500 error
- meta_query not working properly
- Using tax_query reverses my post_type argument in a custom WP_Query
- $wp_query->current_post restarts from zero on paged pages
- wp_get_post_terms of cpt but not duplicates if they are used more than once in the loop
- How to make orderby ‘meta_value_num’ OPTIONAL?
- How to do a query on custom taxonomies that is uncategorised?
- Woocommerce returns Product post_status as published even tho it is in status draft
- remove query arg from url after set query
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- Order By table field comment_status in WordPress > 4.0
- Using hook to use DISTINCT in a wp_query
- Overwrite YoastSEO meta-tags with another page’s [closed]
- Import wp users via one click demo option
- different for loop if screen resolution < 1000px
- Sort by presence of thumbnail
- Link Author URL’s based on a custom field
- embedding shortcodes in php template
- wp-query, pull children of parent page
- How to change tag based on metabox value within $wp_query
- What’s missing in this wp_query and meta_query
- Tax Query on product_cat using NOT IN as operator does not exclude that category
- Random users always showing same 8 users
- whether a nonce is required for get type and get_query_var?
- Showing most popular post of week
- The sorting of posts by a meta_query with two keys fails while separated as single queries it works
- Hierarchical List Pages as a table
- WP_Query with several meta_query-statements and order by meta_value
- Second wp_query doesn’t appear to be working
- difference between methods of query
- post__in not recognizing multiple IDs
- Is there another way to retrieve a post_id from post_meta other than a SQL query?