A few issues-
-
there is no
%book_type%
rewrite tag, your rewrite tags are%book%
and%chapter%
. Change all instances of%book_type%
to%book%
. -
Your taxonomy slug should just be
'rewrite' => array( 'slug' => 'books')
, the rewrite tag shouldn’t be in there. -
Last (minor) issue- In your
post_type_link
filter, you should wrap the fetching of the book term in anif
check so you only try to replace the tag if a term is selected. otherwise, with debugging enabled you’ll see atrying to get property of non-object
notice from trying to get the slug of a non-existent term.if( $book_type_term = wp_get_object_terms( $post->ID, 'book' ) ) $post_link = str_replace( '%book%', array_pop( $book_type_term )->slug, $post_link );
tested and working in twentythirteen theme- visit your permalinks settings page after making changes, to flush rewrite rules, and all should work as expected.
Related Posts:
- Is there a way to use regular categories with custom post types?
- How to show custom taxonomy in the permalink?
- Custom Post Types and independent Categories – complex Taxonomy
- Can’t remove front from permalinks for custom taxonomy category page
- Custom post type category permalinks and archive pages
- Remove slug from Custom Category Permalink + dual-category permalinks
- Is it possible for post and custom post type to share a category base slug?
- Rewriting a custom-post-type permalink with taxonomy term?
- Custom Post Type Permalink / Rewrite not working immediately
- Templates for Custom Post Types and Custom Taxonomies
- Create permalink structure for one taxonomy archive per custom post type
- Custom permalinks
- Understanding Permalinks on Custom Post Types
- Add links to post categories and taxonomies in wysiwyg link modal?
- Glossary with Custom Post Type
- Custom-Taxonomy as categories: Remove “most-used” tab?
- Custom Permalinks for Custom Post Types and Taxonomies
- Custom taxonomy & post slug permalink
- Maintaining WP_Query Relation Among CPT, Custom Taxonomy, Permalinks- CPT UI
- Add filter to wp_list_categories and query what type of taxonomy-terms it use?
- Custom post type category, taxonomy and URL rewrite problem
- Define permalinks for custom post type by taxonomy in WP 3.4
- Remove taxonomy slug when not assigning taxonomy with custom post types
- Custom Post Type: How to display all of same taxonomy?
- Remove “-2” from a Toolset Types URL with the same post name
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Taxonomy structure of Sport site
- Custom post types and permalink
- Programmatically adding posts
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- multiple url slug for single custom post type
- Custom post types, taxonomies, and permalinks
- How to specify URLS for custom posts & taxonomies
- Querying Term Posts in Loop
- Permalinks not working for custom taxonomy on custom post type
- Change Permalink Structure for Tag.php template
- Posts from all the categories are being displayed instead of particular category
- Conditional Statement custom post type category
- Custom Post Type permalink shows wrong page: homepage/index.php
- Categories sorting
- Allow user to set custom order to a list of custom taxonomies?
- wp_list_categories() – current-cat class also inside posts?
- Custom post type url with category
- Adding custom post category slug in permalink causes 404 error for pages and posts
- Limit amount of posts made within a custom taxonomy
- CPT’s with landing page instead of archive – Url Rewrite?
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- Custom post type and taxonomy permalinks
- Hierarchical permalinks for custom post type and taxonomy
- Best way to specify “article type” in URL
- Template files for Custom Post Type and Taxonomy
- in_category for custom post types
- List Posts By Custom Taxonomy
- How to Display Posts From Category Within a Custom Taxonomy?
- Listing all slugs?
- How to filter a custom post type by custom taxonomy without 404
- Get child categories of custom taxonomy category?
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Custom post types category
- Get terms for a specfic post from multiple taxonomies in custom post type
- Using page title as a link to term archive
- Is it possible to have hierarchical taxonomy and hierarchical custom post types in one permalink?
- Custom category URL not displaying posts
- Advanced archive url structure (category, tag and date)
- Duplicate slug/permalink issue while adding same post name
- How to show related posts of category on post within custom posttype
- Error 404 change permalink term custom term taxonomy
- Show Custom Post Type based on Category on Archive Page
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- % encoded URL giving 404 error in WordPress
- Adding categories to custom post type in permalink
- Custom category taxonomy – archive page not showing up
- Issue with Custom Post Types and Permalinks
- Custom post type URL structure with site.com/custom_taxonomy_slug/post_name
- Help with Travel Guide Setup
- Pretty permalink structure with multiple (AND OR) taxonomies
- Custom post type category archive URL redirects to home page
- How to have permalink structure based on taxonomy terms
- Multiple post types or single post type with category taxonomy?
- Get full control over custom post type url
- How to switch from custom post type URL to category URL?
- How can I add a “fake” parent into the permalink?
- Organizing The Custom Post Type with Taxonomies / Parent Posts
- Display 2nd category, only once, as sub-heading, in the loop
- Remove Custom Taxonomy Slug only without removing Custom post type slug in permalinks
- Get a list of categories ids
- Adding 2 CPT with multiple custom taxonomies to permalinks
- Add taxonomy to custom post type archive
- Custom Post Type Permalinks with %category%
- Display a custom post type list by taxonomy term
- Permalinks Works for Custompost type but not with pages Why?
- Return Custom Post Type Categories
- Problem with Custom Post Types, Taxonomy, permalink, Archive
- Highlight specific menu item when custom post is page
- 404 Error On Custom Taxonomy Pages 2, 3, etc
- Different CPT permalink base on taxonomy
- Hide custom post type slug url from search engine [closed]
- Permalinks for Custom Post Types and Taxonomies