Skip to content

Commit 63e73a3

Browse files
committed
Update index.php
Removing empty categories from Sitemap
1 parent 565e408 commit 63e73a3

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

index.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,20 @@ function generate_sitemap() {
109109
sitemap_add_url(osc_base_url(), date('Y-m-d'), 'always');
110110

111111
// Category
112-
if( osc_get_preference('sitemap_categories', 'sitemap_plugin') ) {
113112
if(osc_count_categories () > 0) {
114-
while ( osc_has_categories() ) {
115-
sitemap_add_url(osc_search_category_url(), date('Y-m-d'), 'hourly');
116-
if ( osc_count_subcategories() > 0 ) {
117-
while ( osc_has_subcategories() ) {
118-
sitemap_add_url(osc_search_category_url(), date('Y-m-d'), 'hourly');
119-
}
120-
}
121-
}
113+
while ( osc_has_categories() ) {
114+
if ( osc_category_total_items() > 0 ) {
115+
sitemap_add_url(osc_search_category_url(), date('Y-m-d'), 'hourly');
116+
}
117+
if ( osc_count_subcategories() > 0 ) {
118+
while ( osc_has_subcategories() ) {
119+
if ( osc_category_total_items() > 0 ) {
120+
sitemap_add_url(osc_search_category_url(), date('Y-m-d'), 'hourly');
121+
}
122+
}
123+
}
122124
}
123125
}
124-
125126
// countries
126127
if( osc_get_preference('sitemap_countries', 'sitemap_plugin') ) {
127128
if(osc_count_list_countries() > 0) {
@@ -187,4 +188,4 @@ function sitemap_admin() {
187188
osc_add_hook(osc_plugin_path(__FILE__)."_configure", 'sitemap_admin');
188189

189190

190-
?>
191+
?>

0 commit comments

Comments
 (0)