RavanH / xml-sitemap-feed

XML Sitemap & Google News feeds
GNU General Public License v2.0
16 stars 21 forks source link

Filter Taxonomy Terms #40

Closed DrJoppix closed 7 months ago

DrJoppix commented 1 year ago

Hi RavanH,

Using your plugin I noticed that we can't filter the taxonomy terms, only the root pages and the authors. The only way I found was by using get_terms filters. This way isn't the best option. Is it possible to apply a filter for this request, something like $terms = apply_filters( 'xmlsf_taxonomy_data', $terms, $terms_taxonomy ); before the foreach?

Thank You from Italy!

RavanH commented 1 year ago

Hi @DrJoppix you are trying to exclude certain taxonomy terms? There is indeed no filter for that yet.

I'll add it to the TODO list :)

ericek111 commented 1 year ago

I'd like to include terms without any posts in the sitemap, too ('hide_empty' => false). Would it be possible to add a filter to the argument array passed into get_terms, please? Maybe something like this.

$args = apply_filters('xmlsf_feed_args_taxonomy', ['taxonomy' => get_query_var('taxonomy')]);
$terms = apply_filters('xmlsf_feed_data_taxonomy', get_terms($args));

instead of https://github.com/RavanH/xml-sitemap-feed/blob/3c5020d3f64a76709f4a3dfc95b30ee1ef9ba3c6/views/feed-sitemap-taxonomy.php#L17

RavanH commented 1 year ago

Hi @ericek111 I'll add this to the feature request list. The "hide empty" might even make it as an option ;)

RavanH commented 7 months ago

Update: filtering sitemap entry URLs can now be done with the xmlsf_entry_url filter, read more on https://premium.status301.com/knowledge-base/xml-sitemap-google-news/filter-hooks/xmlsf_entry_url/

In the upcoming version 5.5, a filter xmlsf_taxonomies_query_args is planned. So currently not available yet. But you could set the sitemap Server to WordPress on Settings > XML Sitemap, and then use the WP core filter wp_sitemaps_taxonomies_query_args...