Rewrite Permalink for ‘Ticket’ Post Type
-
I rarely ask for help on these sort of things but this issue is proving somewhat elusive. I was trying to rewrite the permalink for the ‘ticket’ post type. Currently, the permalink for all tickets is http://www.domain.com/ticket/%post_name%
I want the ticket permalink to be based on where the ‘My Tickets’ page is located.
The function below adds a rewrite filter which is applied in the code, this filter didn’t seem to exist yet so I assumed this was put there to create a function and hook for. The code works currently but ends up giving me a permalink of http://www.domain.com/support/tickets/ticket/%post_name% and when I try to remove use of the slug the page won’t load. Any ideas? I imagined this would have been built into the plugin.function wpas_rewrite( $slug ){ $hierarchyString = ''; $ticket_page = wpas_get_option('ticket_list'); $ticket_page_name = get_post($ticket_page)->post_name; foreach (get_post_ancestors($ticket_page) as $page_id){ $page_name = get_post( $page_id )->post_name; $hierarchyString = $page_name . '/' . $hierarchyString; } $hierarchyString .= $ticket_page_name . '/' . $slug; return $hierarchyString; } add_filter( 'wpas_rewrite_slug', 'wpas_rewrite' );
The topic ‘Rewrite Permalink for ‘Ticket’ Post Type’ is closed to new replies.