• In the customizer, we can set the default layout for posts/pages but not custom posts types.
    How do I set the layout for a CPT?
    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @fznshaikh,

    ?There’s no dedicated option for a CPT at the moment. It will inherit the global container layout on the Customizer. Or you can set it individually through Page Specific Astra Settings.

    ??I hope that will help.

    ??Kind regards,
    ?Herman ??

    Thread Starter Fzn.shaikh

    (@fznshaikh)

    There should be code snippet, right?

    Hi @fznshaikh,

    ?I don’t think you will need it. You can just configure it through the global container layout and the CPT layout will inherit it. Or use Page Specific Astra Settings to set a CPT layout individually.
    ?
    ?I hope it helps.
    ?
    ?Kind regards,
    Herman ??

    Thread Starter Fzn.shaikh

    (@fznshaikh)

    I actually need it because I don’t want to individually modify every CPT(there are multiple). And if I use global option, then unexpected then I have to do it manually for posts which I don’t want to have a global settings.
    I’m sure there should be a snippet. If you provide an example, I’ll take care of my requirements. On the Astra facebook group someone else needed the same so he said to contact support so I’m sure there’s a snippet which will save time.

    Hi @fznshaikh,

    Would you please try adding this custom PHP code to your site

    add_filter( 'astra_get_content_layout', 'custom_post_type_content_layout');
    
    // Update the container layout based on Custom Post Type.
    function custom_post_type_content_layout ( $layout ){
        // Add your CPT instead of newspaper, book. If it's only for one CPT then add just one CPT.
        if ( is_singular( array( 'newspaper', 'book' ) ) ) {
            $layout = 'boxed-container'; // This is Boxed layout
        }
        return $layout;
    }?

    Please refer to this doc to know how to add custom PHP code in Astra.

    And please refer to below for the Layout:

    • Full Width / Streched = “page-builderpage-builder”
    • ?Full Width / Contained = “plain-container”
    • ?Content Boxed = “content-boxed-container”
    • ?Boxed = “boxed-container”

    ?I hope that will help.

    ??Kind regards,
    ?Herman ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Set custom layout for different post types’ is closed to new replies.