WordPress Custom Post Type and Taxonomy URLs -


i made custom post type , taxonomy have structure of /episodes archive page show children "terms", /episodes/custom-term show archive of specific term, , /episodes/custom-term/post-title show single posts.

i able /episodes/custom-term working custom term create. however, receiving 404 /episodes 404 /episodes/custom-term/post-title.

in cms, when make post, assuming custom term season 1 , post title sample episode. can go /episodes/season-one , use "taxonomy-episode_category.php" template output posts within season one. knows when creating post permalink /episodes/season-one/sample-episode reaches 404 page.

i not sure go here or if doing wrong.

function episodes() {  $labels = array( 'name'                => _x( 'episodes', 'post type general name', 'text_domain' ), 'singular_name'       => _x( 'episodes', 'post type singular name', 'text_domain' ), 'menu_name'           => __( 'episodes', 'text_domain' ), 'parent_item_colon'   => __( 'parent item:', 'text_domain' ), 'all_items'           => __( 'all episodes', 'text_domain' ), 'view_item'           => __( 'view item', 'text_domain' ), 'add_new_item'        => __( 'add new item', 'text_domain' ), 'add_new'             => __( 'add new episode', 'text_domain' ), 'edit_item'           => __( 'edit item', 'text_domain' ), 'update_item'         => __( 'update item', 'text_domain' ), 'search_items'        => __( 'search item', 'text_domain' ), 'not_found'           => __( 'not found', 'text_domain' ), 'not_found_in_trash'  => __( 'not found in trash', 'text_domain' ) );  $rewrite = array( 'slug'                => 'episodes/%episode_cat%', 'with_front'          => false, 'pages'               => true, 'feeds'               => true ); $args = array( 'label'               => __( 'episodes', 'text_domain' ), 'description'         => __( 'all episodes', 'text_domain' ), 'labels'              => $labels, 'supports'            => array('title' ), 'hierarchical'        => true, 'public'              => true, 'show_ui'             => true, 'show_in_menu'        => true, 'show_in_nav_menus'   => true, 'show_in_admin_bar'   => true, 'menu_position'       => 5, 'can_export'          => true, 'has_archive'         => true, 'exclude_from_search' => false, 'publicly_queryable'  => true, 'rewrite'             => $rewrite, 'capability_type'     => 'page', 'query_var'           => true, '_builtin'            => false ); register_post_type( 'episodes_listing', $args );  }  add_action( 'init', 'episodes', 0 );  function episodes_taxomony() {   $labels = array( 'name'                       => _x( 'episodes categories', 'taxonomy general name', 'text_domain' ), 'singular_name'              => _x( 'episodes', 'taxonomy singular name', 'text_domain' ), 'menu_name'                  => __( 'episode categories', 'text_domain' ), 'all_items'                  => __( 'all items', 'text_domain' ), 'parent_item'                => __( 'parent item', 'text_domain' ), 'parent_item_colon'          => __( 'parent item:', 'text_domain' ), 'new_item_name'              => __( 'new item name', 'text_domain' ), 'add_new_item'               => __( 'add new episode', 'text_domain' ), 'edit_item'                  => __( 'edit item', 'text_domain' ), 'update_item'                => __( 'update item', 'text_domain' ), 'separate_items_with_commas' => __( 'separate items commas', 'text_domain' ), 'search_items'               => __( 'search items', 'text_domain' ), 'add_or_remove_items'        => __( 'add or remove items', 'text_domain' ), 'choose_from_most_used'      => __( 'choose used items', 'text_domain' ), 'not_found'                  => __( 'not found', 'text_domain' ) ); $rewrite = array( 'slug'                       => 'episodes', 'with_front'                 => false, 'hierarchical'               => true  ); $args = array( 'labels'                     => $labels, 'hierarchical'               => true, 'public'                     => true, 'show_ui'                    => true, 'show_admin_column'          => true, 'show_in_nav_menus'          => true, 'show_tagcloud'              => true, 'query_var'                  => true, 'rewrite'                    => $rewrite ); register_taxonomy( 'episodes_category', array('episodes_listing'), $args );  }   add_action( 'init', 'episodes_taxomony', 0 );  function filter_post_type_link($link, $post) {   if ($post->post_type != 'episodes_listing')   return $link;   if ($cats = get_the_terms($post->id, 'episodes_category')) {    $link = str_replace('%episode_cat%', array_pop($cats)->slug, $link);   return $link;  } } add_filter('post_type_link', 'filter_post_type_link', 10, 2); 

turns out pagination working correctly when set permalink structure default instead of post name. use post name able use exact code along new function:

function add_rewrite_rules() {    add_rewrite_rule('episodes/(.+?)/page/?([0-9]{1,})/?$', 'index.php', 'top');  }  add_filter('init', 'add_rewrite_rules') 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -