Created
July 14, 2023 07:57
-
-
Save chikaibeneme/c59aa0fa666f3ac5b92846ce26af44dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function custom_event_permalink_structure($permalink, $post, $leavename) { | |
| // Check if the post type is 'tribe_events' | |
| if ($post->post_type === 'tribe_events') { | |
| // Get the categories assigned to the event | |
| $categories = get_the_terms($post->ID, 'tribe_events_cat'); | |
| // Check if categories are available | |
| if ($categories && !is_wp_error($categories)) { | |
| $category = reset($categories); // Get the first category | |
| $category_name = $category->slug; | |
| // Append category name to the permalink | |
| $permalink = trailingslashit($permalink) . $category_name; | |
| } | |
| } | |
| return $permalink; | |
| } | |
| add_filter('post_type_link', 'custom_event_permalink_structure', 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment