0

I'm getting a 404 page when viewing child-pages of a custom post type. Right now I have a pages (let's call it 'Books') that displays every 'book', and in the menu have other pages listed under Books which are currently giving me a 404 error. Here is my custom post type registration:

$args = array(
    'labels' => $labels,
    'public' => true,
    'exclude_from_search' => false,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'query_var' => true,
    'capability_type' => 'post',
    'hierarchical' => true,
    'menu_link' => 5,
    'supports' => array('title','editor','thumbnail','author', 'page-attributes'),
    'rewrite' => array( 'slug' => __('books', 'sproingcreative') )
  );

I've tried removing 'query_var' => true and even setting it to false, and although setting it to false stopped the 404 error, the individual posts within the CPT no longer work. Has anyone had this issue before?

UPDATE: Changing the page's slug did the trick, it works fine now!

  • Have you tried going to Settings -> Permalinks and pressing save? This will refresh your permalinks. Another thing you can try is to change the slug to something more unique like, for the sake of testing, testbooks, then save your permalinks again and try that. It could be a collision with permalinks in WP. – Howdy_McGee Feb 26 '14 at 20:43
  • Hi Howdy_MgGee, yes I've updated permalinks every time I made an edit, but that didn't seem to do the trick. I'll try changing the slug and will report back! – user2585051 Feb 26 '14 at 20:59
  • How are your templates hierarchy setup? – gdaniel Feb 26 '14 at 21:12
  • 1
    How do you mean gdaniel, aside from in the post type registration? – user2585051 Feb 26 '14 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.