I’m feeling close to finishing this. In short, I can’t seem to display posts.
For example I have:
http://somedomain.org/tours //Displays all categories
http://somedomain.org/tours/gbr //Displays all posts in category
http://somedomain.org/tours/gbr/my-post //Should display post in category
http://somedomain.org/tours/gbr/my-post
doesn’t display, I get a there’s nothing here, 404 error. But if I go to:
http://somedomain.org/toursgbr/my-post
It does in fact, display the post (“toursgbr” has no forward slash if you’re looking for the difference)
I am using the latest WordPress. I am using the plugin:
Custom Post Type Permalinks
I have the following code in the functions.php file:
// Our custom post type function
function create_posttype() {
register_post_type( 'tours',
// CPT Options
array(
'labels' => array(
'name' => __( 'Tours' ),
'singular_name' => __( 'Tour' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'tours', 'with_front' => TRUE),
'cptp_permalink_structure' => '%tour_category%/%postname%',
'hierarchical' => true //A added
)
);
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );
function my_taxonomies_tours() {
$labels = array(
'name' => _x( 'Tour Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Tour Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Tour Categories' ),
'all_items' => __( 'All Tour Categories' ),
'parent_item' => __( 'Parent Tour Category' ),
'parent_item_colon' => __( 'Parent Tour Category:' ),
'edit_item' => __( 'Edit Tour Category' ),
'update_item' => __( 'Update Tour Category' ),
'add_new_item' => __( 'Add New Tour Category' ),
'new_item_name' => __( 'New Tour Category' ),
'menu_name' => __( 'Tour Categories' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'rewrite' => array('slug' => 'tours')
);
register_taxonomy( 'tour_category', 'tours', $args );
}
add_action( 'init', 'my_taxonomies_tours', 0 );
The line of code:
'cptp_permalink_structure' => '%tour_category%/%postname%',
If I add the forward slash, so it’s:
'cptp_permalink_structure' => '/%tour_category%/%postname%',
That’s when I can’t view posts. Any help in the right direction would be fantastic. I do have other categories other than gbr and posts can have multiple categories. I thought that might be important information