Wondering if someone could tell me why sub pages (child pages) no longer work (eg: www.mysite.com/type/childpage).
I have a page called "Type" (working fine), and I wish to have Child Pages of "Type" (404 errors)- as you can see I also like to have the "type" rewrite slug in front of my custom post types/taxonomies.
I tried the method from this link to no avail: https://wordpress.stackexchange.com/questions/4127/custom-taxonomy-and-pages-rewrite-slug-conflict-gives-404
add_action( 'init', 'create_zombie_type' );
function create_zombie_type() {
register_post_type('zombies',
array(
'description' => 'Zombie custom post type',
'show_ui' => true,
'menu_position' => 5,
'menu_icon' => get_stylesheet_directory_uri() . '/images/zombies.png',
'exclude_from_search' => false,
'labels' => array(
'name' => 'Zombies',
'singular_name' => 'Zombie',
'add_new' => 'Add New Zombie',
'add_new_item' => 'Add New Zombie',
'edit' => 'Edit Zombies',
'edit_item' => 'Edit Zombie',
'new_item' => 'New Zombie',
'view' => 'View Zombie',
'view_item' => 'View Zombie',
'search_items' => 'Search Zombies',
'not_found' => 'No zombies found',
'not_found_in_trash' => 'No zombies found in Trash',
'parent' => 'Parent Zombie',
),
'hierarchical' => false,
'supports' => array('title','editor','excerpt', 'trackbacks','custom-fields', 'comments','revisions','thumbnail','author','page-attributes'),
'public' => true,
'rewrite' => array('slug' => 'type/%freshness%', 'with_front' => false),
'taxonomies' => array('freshness')
)
);
}
add_action( 'init', 'create_zombie_taxonomies' );
function create_zombie_taxonomies() {
register_taxonomy(
'freshness',
'zombies',
array(
'labels' => array(
'name' => 'Freshness',
'singular_name' => 'Freshness',
'search_items' => 'Search Freshness',
'popular_items' => 'Popular Freshness',
'all_items' => 'All Freshness',
'parent_item' => 'Parent Freshness',
'parent_item_colon' => 'Parent Freshness:',
'edit_item' => 'Edit Freshness',
'update_item' => 'Update Freshness',
'add_new_item' => 'Add New Freshness',
'new_item_name' => 'New Freshness Name'
),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'query_var' => 'freshness',
'show_tagcloud' => true,
'rewrite' => array( 'slug' => 'type', 'with_front' => false )
)
);
}
function filter_post_type_link($link, $post)
{
if ($post->post_type != 'zombies')
return $link;
if ($cats = get_the_terms($post->ID, 'freshness'))
$link = str_replace('%freshness%', array_pop($cats)->slug, $link);
return $link;
}
add_filter('post_type_link', 'filter_post_type_link', 10, 2);