Support

Home Forums Event Espresso Premium Sitemaps (again)

Sitemaps (again)

Posted: May 25, 2016 at 9:08 am

Viewing 5 reply threads


dee4dogs

May 25, 2016 at 9:08 am

Following on from this conversation:
https://eventespresso.com/topic/sitemaps/

Is there any way to ONLY show the CURRENT events in the Sitemap? So the events that have passed/expired are not listed?

Thanks


dee4dogs

May 25, 2016 at 9:49 am

My plugin script now reads:

*/

function jeherve_add_cpt_sitemaps( $post_types ) {
	$post_types[] = 'espresso_events';
	return $post_types;
}
add_filter( 'jetpack_sitemap_post_types', 'jeherve_add_cpt_sitemaps' );

function jeherve_exclude_post_sitemap( $skip, $post ) {
        if ( 'WHAT DO I PUT HERE' ==  WHAT DO I PUT HERE ) {
                $skip = true;
        } else {
                $skip = false;
        }

        return $skip;
}
add_filter( 'jetpack_sitemap_skip_post', 'jeherve_exclude_post_sitemap', 10, 2 );


Josh

  • Support Staff

May 25, 2016 at 10:18 am

Yes I checked and Jetpack has a filter to skip posts so they’re not included in the XML site map.
jetpack_sitemap_skip_post

Here’s a thread where they show how to use the filter:

https://wordpress.org/support/topic/using-the-jetpack_sitemap_skip_post-filter#post-8030024

You could build a query to do a JOIN on the _esp_datetime. table to get the last DTT_EVT_end for that event, then if it’s past, set it to skip. The only trouble I’m seeing with this is how to make this query efficient so it doesn’t really slow down the site when that query runs.


dee4dogs

May 25, 2016 at 10:25 am

OK. Let’s look at this another way. Would sending the event to Trash remove it from the Sitemap?


dee4dogs

May 25, 2016 at 10:40 am

OR – can I check for a “Trashed” attribute to then miss it out of the sitemap?

I’m completely out of my depth with coding now.


Josh

  • Support Staff

May 25, 2016 at 12:21 pm

The way the code works in the Jetpack site maps script is it checks for posts with the “Published” post status. So if an event is set to be in trash (or any other post status that’s not “Published”) it will be removed from the site map the next time the site map is generated.

Viewing 5 reply threads

The support post ‘Sitemaps (again)’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso