[Plugin: Google XML Sitemaps] Exclude Pages By Parent ID
-
I mainly use Pages (not Posts) and wanted a way to exclude Pages by the ID of their parent. Since Google XML Sitemaps didn’t have this feature built in, I implemented it myself. I’m here to share the simple code.
Starting Line 1762 of sitemap-core.php, insert the following block:
foreach ($excludes as $exclude) { $children = get_pages(array('child_of' => $exclude)); foreach ($children as $child) $exChildren[] = $child->ID; }
Then at Line 1781, insert:
if (is_array($exChildren)) $excludes = array_merge($exChildren, $excludes);
That’s it. If your blog breaks as a result of this, I’m not responsible.
Best,
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘[Plugin: Google XML Sitemaps] Exclude Pages By Parent ID’ is closed to new replies.