Good day, dear specialists. There is such a code
$categoriesForSitemap = get_categories(array(
'hide_empty' => 1,
'depth' => 0,
'hierarchical' => false
));
foreach($categoriesForSitemap as $category) {
$category_link = get_category_link($cat->cat_ID);
$sitemap .= '<url>' . '<loc>' . get_category_link($category->term_id) . '</loc>' . '<priority>1</priority>' . '<lastmod></lastmod>' . '<changefreq>daily</changefreq>' . '</url>';
}
How can I enable adding all category pages in it? Those.
category-name/page/2/
category-name/page/3/
.....
and so on.
Plase help me. Sorry for my English.
2
Answers
You are using WordPress so why not just use a plugin that does it for you already? There must be a plugin that is free that supports this already.
First, there is no
depth
option inget_categories()
.Second, you set the
hide_empty
andhierarchical
parameters yourself – as a result, you will no have ALL categories.Thirdly, in the loop you refer to
$cat->cat_ID
– it is not at all clear what.My advice is read the documentation before asking questions on stackoverflow.