Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The Events Calendar: All Venue slugs get prefixed with a custom string. Works in wp-admin and Community Events.
<?php
/**
* The Events Calendar: All Venue slugs get prefixed with a custom string. Works in wp-admin and Community Events.
*
* !!! Change the prefix to your own !!!
*
* @link https://gist.github.com/cliffordp/ac4a68769787352369ab0c5e41dc28ab This snippet.
*/
function cliff_prefix_venue_slugs( $data ) {
// TODO: Change this to what you want!!!
$prefix = 'xvenue-';
if (
(
'publish' === $data['post_status']
|| 'draft' === $data['post_status']
|| 'pending' === $data['post_status']
)
&& class_exists( 'Tribe__Events__Venue' )
&& Tribe__Events__Venue::POSTTYPE === $data['post_type']
&& 0 !== strpos( $data['post_name'], $prefix ) // is not already prefixed, such as when moving from Deleted back to Published
) {
$data['post_name'] = $prefix . $data['post_name'];
}
return $data;
}
add_filter( 'wp_insert_post_data', 'cliff_prefix_venue_slugs' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.