1. Documentation
  2. How to
  3. Set up a custom post type with a full-width layout

Set up a custom post type with a full-width layout

Our themes are designed to support unlimited Custom Post Types (CPTs). You can register your CPTs with any name, and our theme will automatically apply the default layout and styling for newly created CPT pages.

When you create a custom post type, many of the built-in KeyDesign features will automatically apply. However, the default page layout may include a container and sidebar, which might not be ideal for all CPTs – especially if you’re aiming for a clean, full-width canvas.

You’ll need to manually remove the container and sidebar using custom code to achieve a full-width blank layout for your custom post type pages.

This method requires having the child theme installed and activated – learn how to install the child theme.

Note:

Using a child theme’s functions.php file allows you to add custom code without directly modifying the main theme. This ensures that your changes are safe and will not be lost during theme updates.

How to remove the container and sidebar for your CPT

Follow the steps below to apply a full-width layout to your custom post type pages:

  1. Open your child theme’s functions.php file.
  2. Add the following code snippet:
function keydesign_cpt_template_actions() {
    if ( is_singular( 'showcase' ) ) {
        // Remove page title
        remove_action( 'keydesign_content_top', 'keydesign_display_page_title' );
        // Remove sidebar
        add_filter( 'keydesign_show_sidebar', '__return_false' );
        // Remove container markup
        remove_action( 'keydesign_content_top', 'keydesign_container_top_markup', 20 );
        remove_action( 'keydesign_content_bottom', 'keydesign_container_bottom_markup' );
    }
}
add_action( 'wp', 'keydesign_cpt_template_actions', 15 );
  1. Replace ‘showcase’ in the is_singular() function with the name of your custom post type.
  2. Save your changes.

Once the code is added and your CPT is published, the corresponding pages will display without the container and sidebar – resulting in a full-width, clean layout.

Was this article helpful?