Title: Rewrite Permalink for &#8216;Ticket&#8217; Post Type
Last modified: June 4, 2018

---

# Rewrite Permalink for ‘Ticket’ Post Type

 *  Resolved [fattycraft](https://wordpress.org/support/users/fattycraft/)
 * (@fattycraft)
 * [8 years ago](https://wordpress.org/support/topic/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%](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%](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' );
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Author [awesomesupport](https://wordpress.org/support/users/awesomesupport/)
 * (@awesomesupport)
 * [8 years ago](https://wordpress.org/support/topic/rewrite-permalink-for-ticket-post-type/#post-10363253)
 * Hi:
 * The wpas_rewrite_slug filter is only executed once – when the TICKET post type
   is defined. So, you can change the name of the slug from something like “tickets”
   to “help” but I don’t think you can change it to “/support/tickets/help”.
 * If you need to change it one level you can do that without writing code by setting
   the WPAS_SLUG variable in the wp-config.php file (see documentation here: [https://getawesomesupport.com/documentation/awesome-support/admin-wp-config-options/](https://getawesomesupport.com/documentation/awesome-support/admin-wp-config-options/)).
 * I did a search to see what resources there might be to do what you’re trying 
   to do and came up with this article that might help: [https://www.ibenic.com/custom-wordpress-rewrite-rule-combine-taxonomy-post-type/](https://www.ibenic.com/custom-wordpress-rewrite-rule-combine-taxonomy-post-type/).
 * Thanks.

Viewing 1 replies (of 1 total)

The topic ‘Rewrite Permalink for ‘Ticket’ Post Type’ is closed to new replies.

 * ![](https://ps.w.org/awesome-support/assets/icon-256x256.png?rev=1849681)
 * [Awesome Support - WordPress HelpDesk & Support Plugin](https://wordpress.org/plugins/awesome-support/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/awesome-support/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/awesome-support/)
 * [Active Topics](https://wordpress.org/support/plugin/awesome-support/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/awesome-support/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/awesome-support/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [awesomesupport](https://wordpress.org/support/users/awesomesupport/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/rewrite-permalink-for-ticket-post-type/#post-10363253)
 * Status: resolved