Support » Developing with WordPress » when custom posts work normal pages and posts do not

  • Hi I am working on a custom theme for somebody and I have created a two custom posts types that are linked. I have those registered and working fine and the links work fine.
    As soon as I flush the permalinks those pages work but on the main site the only page that can still be displayed is the home page all the other pages show as 404.

    I have checked it does not appear to be the custom permalink stucture that causes the pages to stop working simply just registering the custom posts stops everything else from working.

    add_action( 'init', 'my_cpt_init' );
    
    function my_cpt_init() {
    
        register_post_type( 'brand',
            array(
                'labels' => array(
                    'name' => __( 'Boat Brands' ),
                    'singular_name' => __( 'Boat Brand' )
                ),
                'hierarchical' => true,
                'public' => true,
                'rewrite' => array('slug' => '/','with_front' => false,),
                'show_in_rest' => true,
                'supports' => array('title','editor','author','thumbnail','custom-fields','revisions','page-attributes')
            )
        );
    
        register_post_type( 'boat',
            array(
                'labels' => array(
                    'name' => __( 'Boats' ),
                    'singular_name' => __( 'Boat' )
                ),
                'hierarchical' => false,
                'public' => true,
                'show_in_rest' => true,
                'supports' => array('title','editor','author','thumbnail','custom-fields','revisions','page-attributes')
            )
        );
    
    }

    I am confused and beating my head against the wall 🙂

Viewing 1 replies (of 1 total)
  • Joy

    (@joyously)

    You have defined the rewrite for ‘brand’ to be ‘/’. That will mess up all your other rewrites.
    Isn’t ‘brand’ a taxonomy, and not a post type?

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.