Created
March 16, 2026 19:06
-
-
Save dhirenpatel22/e1a1f162e378db42d8497ef2ee10151e to your computer and use it in GitHub Desktop.
Remove child category from Yoast SEO Sitemap.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Remove child category from Sitemap.xml | |
| add_filter( 'wpseo_sitemap_url', 'sitemap_exclude_taxonomy' ); | |
| function sitemap_exclude_taxonomy( $url = null, $type = null, $term = null ) { | |
| $dataurl = $url; | |
| $url = explode('brands/',$url); | |
| $url_data = explode('/',$url[1]); | |
| $term_slug = $url_data[0]; | |
| $texonomy = get_term_by('slug', $term_slug , "wsac_cse_make"); | |
| if(!$texonomy->parent) | |
| { | |
| return $dataurl; | |
| } | |
| } | |
| add_filter('wpseo_sitemap_exclude_empty_terms', 'return_false'); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment