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?
- How to get the proper category in permalink with custom post type assigned to multiple categories
- Custom taxonomy in URL showing 404
- Display all posts in main category and 1 subcategory
- Custom Post Type Archive Page Filtering
- How can I auto-assign a CPT post to category in a custom taxonomy when published?
- Posts from all the categories are being displayed instead of particular category
- Conditional Statement custom post type category
- Custom Post Type With Categories
- Custom Post Type permalink shows wrong page: homepage/index.php
- Categories sorting
- Allow user to set custom order to a list of custom taxonomies?
- get_category_parents for custom post type taxonomy
- wp_list_categories() – current-cat class also inside posts?
- How to hook custom taxonomies to custom post types and make the permalinks work?
- Categories of custom taxonomy don’t show any posts
- How to display custom taxonomies with links in filter menu?
- Show a Category X’s custom post type on Category X archive page?
- Custom post type url with category
- Adding custom post category slug in permalink causes 404 error for pages and posts
- Cannot add category or custom taxonomy from admin. WordPress site is hosted in Windows 16 server via IIS. No XAMPP or WAMP
- Add custom post type settings to wordress default posts
- How Can I Change the Custom Post Type Slug to the Taxonomy Slug in the URL?
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- How to have the same url structure for both a CPT and a Taxonomy?
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- create a subcatagory for a custom post type and out put url as posttype/subcategory/item
- Hide parent categories when clicked, and show it’s childs
- Limit amount of posts made within a custom taxonomy
- custom-taxonomy/post_name instead of the default post_type/post_name
- Show custom post archive when custom post not specified
- Show custom post type relationships by taxonomy
- Filter CPT posts by one or more categories
- Getting categories of posts under a custom taxonomy
- Removing custom post type slug from URL
- Customize Custom Post Type URL
- Remove CPT name from permalink but add %category% instead
- Permalinks /country/city/cpt/postname/
- Seamless permalinks between Custom Taxonomy and Custom Posts
- Custom post type and custom taxonomy with the same slug using the file page taxonomy only as directory
- Custom Permalinks with CPT and Hierarchical Taxonomies
- How to edit this code to get the categories in achieve page?
- How to have this permalink structure: post_type/postname/custom_inner_page
- Hierarchy and access control for Custom Post Types (CPT)
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- Custom taxonomy returns 404
- Best method to make posts searchable, sortable and filterable – custom field, tag or category?
- How to get custom posts sub category link
- Permalinks: custom post type -> custom taxonomy -> post
- CPT’s with landing page instead of archive – Url Rewrite?
- How to change permalink to include custom post type
- Custom post type, permalinks, taxonomies and blog posts
- Custom post type permalink tag 404
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- browse by category and tags?
- permalink /category/post-name with custom post type and taxonomy
- 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
- List of Posts and Categories
- set permalink for CPT
- Custom permalink with child taxonomy terms
- Custom post type Permalinks with hierarchical Taxonomies
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- WP the_posts() on single-cars.php get category link
- How to solve this custom post type goes to 404 page?
- Best way to specify “article type” in URL
- Template files for Custom Post Type and Taxonomy
- in_category for custom post types
- Get parent category id from child category page for custom taxonomy
- Can’t use pagination with custom taxonomy
- How to add current custom taxonomy slug to body class
- List Posts By Custom Taxonomy
- get_category_link() for custom post type does not include custom slug rewrite?
- How to Display Posts From Category Within a Custom Taxonomy?
- Disable custom taxonomy on admin bar
- Why does my taxonomy have a category style div id?
- Targeting categories in custom fields
- Listing all slugs?
- Template for custom post type when taxonomy is in the URL
- Permalink problems with custom post type and custom taxonomy
- category list with cutom post count
- The Difference Between Categories and Tags and Taxonomies and Terms
- Include custom post type custom taxonomies in Categories widget
- Custom Post Type Categories URL not displaying posts
- Custom Post Type Advanced Slug
- How to filter a custom post type by custom taxonomy without 404
- How to get all posts related to particular category name on button click?
- WordPress custom permalink and archive link for custom post type
- Custom post type categories gives 404 error
- Ideas on how to organize a project [closed]
- get_terms() parent, child and grandchild
- Get child categories of custom taxonomy category?