I have a strange behaviour in some of my wordpress sites or maybe I am just to stupid to find the error…

I created a CPT called product and a single-product.php file to display the single page. When I call a single that doesn’t exist, normally it should display a 404 page but instead it loads the home.php file and if this one doesn’t exists it loads the index.php file. Also in the body_class it loads the class blog instead of the class page-404.

I’ve set up the CPT like that:

    $labels = array(
        'name'               => _x( 'Produkte', 'post type general name'),
        'singular_name'      => _x( 'Produkt', 'post type singular name'),
        'menu_name'          => _x( 'Produkte', 'admin menu'),
        'name_admin_bar'     => _x( 'Produkt', 'add new on admin bar'),
        'add_new'            => _x( 'Add New', 'Produkt'),
        'add_new_item'       => __( 'Add New Produkt'),
        'new_item'           => __( 'New Produkt'),
        'edit_item'          => __( 'Edit Produkt'),
        'view_item'          => __( 'View Produkt'),
        'all_items'          => __( 'All Produkte'),
        'search_items'       => __( 'Search Produkt'),
        'parent_item_colon'  => __( 'Parent Produkt:'),
        'not_found'          => __( 'No Produkte found.'),
        'not_found_in_trash' => __( 'No Produkte found in Trash.'),
    );
    $supports = array(
        'title','editor','thumbnail','page-attributes'
    );
    $args = array(
        'labels'             => $labels,
        'public'             => true,
        'publicly_queryable' => true,
        'show_ui'            => true,
        'show_in_menu'       => true,
        'query_var'          => true,
        'rewrite'            => array('slug' => 'produkte','with_front' => false),
        'capability_type'    => 'post',
        'has_archive'        => false,
        'hierarchical'       => false,
        'menu_position'      => 7,
        'supports'           => $supports,
        'menu_icon'          => 'dashicons-album'
    );
    register_post_type('produkt',$args);

Single Page (working):
http://gametime.ch/en/product/red-dead-redemption-2/

Single Page (should load 404):
http://gametime.ch/en/product/404/

The same problem exists with all my other CPT’s on my website e.g.
/services/die-neusten-spiele/ |
/en/services/404/

Does anyone experienced a similar problem or has a solution for that bug?

Thank you for any help

Read more here: WordPress CPT inexistent post loads blog page


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: