Filters to modify URL’s and drop posts
-
Hi, this plugin works really well and is well written in my opinion. Thanks for the hard work!
I have a small feature that I have added into the plugin on a site I’m working on. I was wondering if it would be possible to get it added into the plugin so other people can benefit and I don’t have to patch every future update.
The code is just adding a couple of filters to
SimpleWpMapBuilder::generateContent()
. one is to allow people to drop posts they don’t want in the site map. The other is to allow people to modify the URL that is added to the sitemap based on the post.I totally understand if you don’t want to add this in but I thought it would be worth an ask.
Here is the code:
global $post; // return falsy value to skip post if(!apply_filters('simple-wp-sitemap_drop_post', $post)) continue; // return a different URL for post $url = apply_filters('simple-wp-sitemap_url', esc_url(get_permalink()), $post);
This goes inside the loop after
$q->the_post();
and the URL filter would replace the line that assigns a value to $url.I would be happy to email in a diff patch or submit a pull request if theres a github page some where. I couldn’t find a git page for the plugin.
- The topic ‘Filters to modify URL’s and drop posts’ is closed to new replies.