Skip to content

Instantly share code, notes, and snippets.

@wp-seopress
Last active June 17, 2025 09:23
Show Gist options
  • Save wp-seopress/718bc5cf7369241c3a65a9ea58aabaef to your computer and use it in GitHub Desktop.
Save wp-seopress/718bc5cf7369241c3a65a9ea58aabaef to your computer and use it in GitHub Desktop.
Filter terms in HTML sitemap titles
add_filter('seopress_sitemaps_html_display_terms_only', 'sp_sitemaps_html_display_terms_only', 10, 2);
function sp_sitemaps_html_display_terms_only($display_terms_only, $cpt_key) {
// Display terms only for products
if ($cpt_key == 'product') {
return true;
}
return $display_terms_only;
}
add_filter('seopress_sitemaps_html_term_name', 'sp_sitemaps_html_term_name', 10, 2);
function sp_sitemaps_html_term_name($term_name, $term) {
// Modify term name for products
if ($term->taxonomy == 'product_cat') {
return 'Product Category: ' . $term_name;
}
return $term_name;
}
add_filter('seopress_sitemaps_html_terms_output', 'sp_sitemaps_html_terms_output', 10, 3);
function sp_sitemaps_html_terms_output($html, $terms, $cpt_key) {
// Modify the terms HTML output
if ($cpt_key == 'product') {
return 'Product Terms: ' . $html;
}
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment