MOD: Include subpages in SimpleSEO
Posted: Fri Apr 28, 2023 5:21 pm
The way I'm using WCMS, I have a hidden top-level menu item that does nothing but hold subpages I don't want in the menu. I would, however, like to have the subpages (that are not themselves hidden) in the sitemap.
SimpleSEO doesn't descend into the subpages. It only looks at the top level. So, this mod is good for that, too.
The following mod drills into the subpages, and it is recursive. You can have as many levels of subpages as you need.
This is for the version 3.2.1 of simple-seo.php
Find the following comment and foreach:
and replace the entire foreach with this:
At the top of the script, after the global $Wcms, add this function:
The sitemap.txt will now include any subpages that are not hidden.
Ideally, if someone would like to tackle it (I'm not interested), on the admin page there should be a checkbox for "Include subpages?"
SimpleSEO doesn't descend into the subpages. It only looks at the top level. So, this mod is good for that, too.
The following mod drills into the subpages, and it is recursive. You can have as many levels of subpages as you need.
This is for the version 3.2.1 of simple-seo.php
Find the following comment and foreach:
Code: Select all
// CMS pages
foreach ($Wcms->get('config', 'menuItems') as $item) {
Code: Select all
foreach ($Wcms->get('config', 'menuItems') as $item) {
simpleSeoPage($item, $output, $BASE_URL);
}
Code: Select all
function simpleSeoPage($item, &$output, $BASE_URL) {
if ($item->visibility !== 'hide') {
$output[] = $BASE_URL . $item->slug;
}
foreach ($item->subpages as $subpage) {
simpleSeoPage($subpage, $output, $BASE_URL . $item->slug . '/');
}
}
Ideally, if someone would like to tackle it (I'm not interested), on the admin page there should be a checkbox for "Include subpages?"