• Hello, I upgraded to 4.0 and my CPT now returns 404 error, I register my CPT like this:

    function create_post_type() {
    	$labels = array(
    		'name'               => 'Staff',
    		'singular_name'      => 'Staff'
    	);
    	$args = array(
    		'labels'              => $labels,
    		'description'         => "Description",
    		'public'              => true,
    		'exclude_from_search' => true,
    		'publicly_queryable'  => true,
    		'show_ui'             => true,
    		'show_in_nav_menus'   => false,
    		'show_in_menu'        => true,
    		'show_in_admin_bar'   => true,
    		'menu_position'       => 20,
    		'menu_icon'           => null,
    		'capability_type'     => 'post',
    		'hierarchical'        => true,
    		'supports'            => array('title','editor','thumbnail','custom-fields','page-attributes'),
    		'has_archive'         => false,
    		'rewrite'             => false,
    		'query_var'           => true,
    		'can_export'          => true
    	);
    	register_post_type('my_staff', $args);
    }
    add_action('init', 'create_post_type');

    If I change ‘hierarchical’ to false, everything works, but the thing is that I need ‘hierarchical’ set to true, which is currently giving me 404 error, if I try to view my post. Has anyone encountered this problem after 4.0? Is there a fix?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Tools > Permalinks > Save Update, maybe.

    OR e
    Exclude_from_search
    (boolean) (importance) Whether to exclude posts with this post type from front end search results.
    Default: value of the opposite of public argument
    ‘true’ – site/?s=search-term will not include posts of this post type.
    ‘false’ – site/?s=search-term will include posts of this post type.
    Note: If you want to show the posts’s list that are associated to taxonomy’s terms, you must set exclude_from_search to false (ie : for call site_domaine/?taxonomy_slug=term_slug or site_domaine/taxonomy_slug/term_slug). If you set to true, on the taxonomy page (ex: taxonomy.php) WordPress will not find your posts and/or pagination will make 404 error…

    Thread Starter GeorgB

    (@georgb)

    Permalinks are not the problem, for now it seems that ‘hierarchical’ set to true gives 404 when you try to view that post, no matter what. I checked exclude_from_search and set it to false, it didn’t change anything, still giving me 404. Any other ideas?

    We are having the same problem.
    It started occurring with the upgrade to WordPress 4.0
    Custom post types now give a 404 Not Found

    Setting hierarchical to false also solves the problem.
    We need this hierarchical though to create ‘pretty’ permalinks and rewrite them.

    I guess something changed in WordPress 4.0
    I wonder if this is a bug and if it will be solved.

    We will start digging here, hopefully we can try and contribute something.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘CPT gives 404’ is closed to new replies.