Site logo

[Support request] Custom post-type Archive & Single Page Showing 404 Error

Home Forums Support [Support request] Custom post-type Archive & Single Page Showing 404 Error

Home Forums Support Custom post-type Archive & Single Page Showing 404 Error

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1716281
    Samuel

    I have created a custom post-type which name is Portfolio. After creating a post-type I updated Permalink. But When I am going to a custom post-type archive page or single page it’s showing a 404 error.

    This is the archive page: https://dc1.justcreative.com/portfolio-item/
    This is the single page: https://dc1.justcreative.com/portfolio-item/primitive/

    Here is the custom post type code:

    function jc_portfolio_post_type() {
    	$labels = array(
    		'name'                  => _x( 'Portfolio', 'Post Type General Name', 'jc' ),
    		'singular_name'         => _x( 'Portfolio', 'Post Type Singular Name', 'jc' ),
    		'menu_name'             => __( 'Portfolio', 'jc' ),
    		'name_admin_bar'        => __( 'Portfolio', 'jc' ),
    		'archives'              => __( 'Item Archives', 'jc' ),
    		'attributes'            => __( 'Item Attributes', 'jc' ),
    		'parent_item_colon'     => __( 'Parent Item:', 'jc' ),
    		'all_items'             => __( 'All Items', 'jc' ),
    		'add_new_item'          => __( 'Add New Item', 'jc' ),
    		'add_new'               => __( 'Add New', 'jc' ),
    		'new_item'              => __( 'New Item', 'jc' ),
    		'edit_item'             => __( 'Edit Item', 'jc' ),
    		'update_item'           => __( 'Update Item', 'jc' ),
    		'view_item'             => __( 'View Item', 'jc' ),
    		'view_items'            => __( 'View Items', 'jc' ),
    		'search_items'          => __( 'Search Item', 'jc' ),
    		'not_found'             => __( 'Not found', 'jc' ),
    		'not_found_in_trash'    => __( 'Not found in Trash', 'jc' ),
    		'featured_image'        => __( 'Featured Image', 'jc' ),
    		'set_featured_image'    => __( 'Set featured image', 'jc' ),
    		'remove_featured_image' => __( 'Remove featured image', 'jc' ),
    		'use_featured_image'    => __( 'Use as featured image', 'jc' ),
    		'insert_into_item'      => __( 'Insert into item', 'jc' ),
    		'uploaded_to_this_item' => __( 'Uploaded to this item', 'jc' ),
    		'items_list'            => __( 'Items list', 'jc' ),
    		'items_list_navigation' => __( 'Items list navigation', 'jc' ),
    		'filter_items_list'     => __( 'Filter items list', 'jc' ),
    	);
    	$rewrite = array(
    		'slug'                  => 'portfolio-item',
    		'with_front'            => true,
    		'pages'                 => true,
    		'feeds'                 => true,
    	);
    	$args = array(
    		'label'                 => __( 'Portfolio', 'jc' ),
    		'description'           => __( 'Post Type Description', 'jc' ),
    		'labels'                => $labels,
    		'supports'              => array( 'title', 'editor', 'thumbnail', 'revisions' ),
    		'taxonomies'            => array( 'portfolio_filter' ),
    		'hierarchical'          => false,
    		'public'                => true,
    		'show_ui'               => true,
    		'show_in_menu'          => true,
    		'menu_position'         => 5,
    		'show_in_admin_bar'     => true,
    		'show_in_nav_menus'     => true,
    		'can_export'            => true,
    		'has_archive'           => true,
    		'exclude_from_search'   => false,
    		'publicly_queryable'    => true,
    		'rewrite'               => $rewrite,
    		'capability_type'       => 'page',
    	);
    	register_post_type( 'portfolio', $args );
    }
    add_action( 'init', 'jc_portfolio_post_type', 0 );
    #1716347
    David
    Staff
    Customer Support

    Hi there,

    have you created the associated templates ( in a child theme ) for your CPT ?

    Here’s a basic example:

    https://docs.generatepress.com/article/setting-up-a-simple-custom-post-type/

    #1716492
    Samuel

    Yes, I have created associated templates in Child Theme.

    #1717523
    David
    Staff
    Customer Support

    Have you checked your permalink settings ?

    #1718158
    Samuel

    My permalink has ok. Please, check this image

    My permalink has ok. Please, check this image

    #1718443
    Elvin
    Staff
    Customer Support

    Can you try changing the common settings to this?:
    https://share.getcloudapp.com/yAuDo5j2

    #1719932
    Samuel

    Yes, I have cleared Cache from website.

    Right now my custom post type slug is portfolio-item. When I am using a prefix with slug (such as new-portfolio-item) then custom post-type Archive & Single Page both page working fine.

    Problem just on this slug name portfolio-item.

    #1720767
    David
    Staff
    Customer Support

    does your slug and cpt template names match ?

    #1721627
    Samuel

    Yes, the template name match with CPT.

    #1722403
    Tom
    Lead Developer
    Lead Developer

    Strange that changing the slug makes it work. Maybe you have a conflicting plugin with the portfolio-item slug?

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.