Created
May 16, 2023 03:20
-
-
Save dantetesta/c20760683328cc868e1976d1ebc9d042 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_tickets_rewrite_rule() { | |
add_rewrite_rule( | |
'tickets/([0-9]+)/?$', | |
'index.php?post_type=tickets&p=$matches[1]', | |
'top' | |
); | |
} | |
add_action('init', 'custom_tickets_rewrite_rule', 10, 0); | |
function custom_post_type_link( $post_link, $post ) { | |
if ( 'tickets' === $post->post_type && 'publish' === $post->post_status ) { | |
return home_url( "/tickets/" . $post->ID ); | |
} | |
return $post_link; | |
} | |
add_filter( 'post_type_link', 'custom_post_type_link', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment