So, I’ve got an entirely custom theme which has a number of custom post-types.
I’ve also got a custom taxonomy which I can visit on the front end with URLs such as:
www.mysite.local/custom-tax/custom-term
Which runs a query giving me results of posts that match the term ‘custom-term’ in the tax ‘custom-tax’. Also paginates, etc.
When it comes to the custom post type pages, e.g. I’ve got a CPT of ‘submissions’ with the permalink slug set to ‘your-reviews’, the backend suggests the permalink will be:
www.mysite.local/your-reviews/my-new-awesome-post/
Which 404’s.
I’ve checked out the WP template hierarchy and everything falls back to index.php which routes to the various custom templates that need to be used depending on the part of the site the user is visiting etc. So if I change the first line in index.php to a
die
or
wp_die
I’d expect no matter which page I visit, I’d always get the message in the die statement even for the 404’ing custom post type page.
It’s worth noting that I get a 404 whether I visit the ‘archive’ page at:
www.mysite.local/your-reviews/
Or the individual page (some of which are ‘hierarchical’ and produce a permalink such as (the non-hierarchical pages also 404).
www.mysite.local/your-reviews/my-parent/my-new-awesome-post/
Updated
So, the code that generates this specific CPT (alongside a few others) is:
define( 'LL_POSTTYPE_ONELINER', 'll_submissions' );
$args = array(
'label' => __('Submissions'),
'labels' => $labels,
'public' => true,
'can_export' => true,
'show_ui' => true,
'_builtin' => false,
'_edit_link' => 'post.php?post=%d', // ?
'capability_type' => 'post',
'menu_icon' => get_bloginfo('template_url').'/images/thumb_up.png',
'hierarchical' => true,
'rewrite' => array( "slug" => "submissions" ),
'supports'=> array('title', 'thumbnail','page-attributes' ) ,
'show_in_nav_menus' => true,
'query_var' => true,
'taxonomies' => array()
);
register_post_type( LL_POSTTYPE_ONELINER, $args);
Note, whilst this one’s marked as ‘hierarchical’ => ‘true’, others that aren’t hierarchical also 404 in the same way.
And to follow up, from the reply I’ve had so far, out of the template hierarchy (single.php, etc…) I only have index.php
which it never hits.
Your Custom Post Type is using the single.php and (most likely) archive.php templates.
A single CPT post looks for templates in this order:
Other CPT pages look for templates in this order:
Have you flushed your permalinks? Whenever you change a Custom post type or taxonomy you must flush permalinks else you’ll get 404s