Auctollo / google-sitemap-generator

GNU General Public License v2.0
11 stars 11 forks source link

Custom exclusion of posts and products #196

Open Obi-nine opened 7 months ago

Obi-nine commented 7 months ago

Hi,

I do like your plugin, but it is missing a key feature, which is to be able to hook to the the feature to exclude post IDs. Adding exclusions by input is not maintainable if we need exclude custom product id's that have special terms.

It is possible to do this with the function and hook below. Which works to an extent. The problem is the it doesnt exclude all ID's that are added in the sitemap exclusion array. I have checked if the desired id is in the list sm_b_exclude, which it is, but still i can still see the link to the product in the sitemap. This is very important as we do not want to canabalize the pages.

Otherwise simple and easy to use plugin. It would be nice if you can either add a hook to modify the exlusion of post ID's or fix that all id's in the exclusion array are removed from the sitemap.

Thank you and have a nice day!


add_filter('pre_update_option_sm_options', [$this,'modify_excluded_sitemap_ids'], 10, 2);

public function modify_excluded_sitemap_ids($new_value, $old_value) { //hides all hidden products from sitemap $hidden_product_ids = $this->exclude_hidden_products_from_sitemap();

   $new_value['sm_b_exclude'] = array_unique($hidden_product_ids);

   return $new_value;
}
Obi-nine commented 7 months ago

Actually the code worked, it i missed adding the id's.