Title: Custom Post Type Rewrite
Last modified: January 23, 2017

---

# Custom Post Type Rewrite

 *  [powerj](https://wordpress.org/support/users/powerj/)
 * (@powerj)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/custom-post-type-rewrite-2/)
 * My rewrites don’t seem to be working. I got them to work by adding
 *     ```
       add_filter('post_type_link', 'events_permalink_structure', 10, 4);
       function events_permalink_structure($post_link, $post, $leavename, $sample)
       {
           if ( false !== strpos( $post_link, '%types%' ) ) {
               $event_type_term = get_the_terms( $post->ID, 'types' );
               $post_link = str_replace( '%types%', array_pop( $event_type_term )->slug, $post_link );
           }
           return $post_link;
       }
       ```
   
 * to the bottom of the posttypes file but the breadcrumb is still not correct. 
   Still just events/postname
 * In Custom Tax I have:
    `'rewrite' => array( 'slug' => 'event-type' ),`
 * And in Custom PT I have:
 *     ```
       'rewrite'            => array( 'slug' => 'events/%types%','with_front' => false ),
       ```
   

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/custom-post-type-rewrite-2/#post-8689589)
 * Rewrite rules are only for interpreting certain URL requests into parameters 
   that WP can understand, they do not affect how links are output. You were correct
   to use a filter for this, that’s how it’s done.
 * You need to look at the code that generates the breadcrumbs, it’s probably not
   sophisticated enough to deal with custom permalink structures.
 *  Thread Starter [powerj](https://wordpress.org/support/users/powerj/)
 * (@powerj)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/custom-post-type-rewrite-2/#post-8690100)
 * Oh thanks so much.
 * I’m using out of the box Genesis breadcrumbs – so I might try the Yoast SEO ones
   and failing that I guess I’ll have to learn how to edit myself.
 * many thanks
 *  Thread Starter [powerj](https://wordpress.org/support/users/powerj/)
 * (@powerj)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/custom-post-type-rewrite-2/#post-8690126)
 * How good are Yoast SEO breadcrumbs! Wow, can’t believe I haven’t used them before
 *  Thread Starter [powerj](https://wordpress.org/support/users/powerj/)
 * (@powerj)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/custom-post-type-rewrite-2/#post-8690248)
 * Wondering if you can shed some light… I’m wondering if my thinking is faulty 
   somewhere.
 * I’ve read lots of the Yoast articles (particular on the new primary category)
   but I don’t really understand why it works the way it does.
 * I have custom post type events – the URL for an individual event is [http://www.website.com.au/postname](http://www.website.com.au/postname)
 * I have a visual navigation on the front page that links to various archive pages
   of event types.
 * If someone clicks on community events, they get breadcrumb home/events/community-
   events and if they click through on one of the events they get breadcrumb home/
   events/community-events/postname – great user experience. **But sometimes it 
   doesn’t work.** If the event has multiple categories say ‘community-event’ and‘
   entertainment’ and entertainment is the primary category – once you click from
   the community events archive page the event will have the breadcrumb home/events/
   entertainment/postname So if the user wants to click back to the archive page
   to keep looking through the community events, they can’t – that to me is a bad
   user experience.
 * Am I doing something wrong – is it bad to have posts in multiple categories?
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/custom-post-type-rewrite-2/#post-8690633)
 * Nope, multiple categories are quite common. However, there is no built in concept
   of a “primary” category. All category terms have equal standing in a post, though
   some terms can be subordinate to parent terms. Even as child terms, they are 
   no less important in a post than their parent. When you query for terms assigned
   to a post, the first term at the top of the list is simply the first one found
   by SQL. (unless a sort order is specified of course)
 * That said, it’s conceivable to create a primary term concept with some custom
   coding. But there will be no ready made breadcrumb code that would recognize 
   such a concept.
 * I understand what you’re looking for as a breadcrumb, but that’s not how most
   breadcrumb implementations work. Most breadcrumb trails actually represent a 
   fixed hierarchical structure. You are looking for more of a navigation road map.
 * It may not be all that difficult to build a road map style breadcrumb trail. 
   Tracking which pages a visitor visits is pretty easy. The details of clearly 
   representing that in a trail might be tricky. Still, you may have trouble finding
   such an implementation. All the ones I’ve seen are of the fixed hierarchy type.
   But I haven’t seen everything, there could be something out there.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Custom Post Type Rewrite’ is closed to new replies.

## Tags

 * [Yoast](https://wordpress.org/support/topic-tag/yoast/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 5 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/custom-post-type-rewrite-2/#post-8690633)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
