Site logo

Archived topic

Custom Post Archive grid layout with Elements Content Block

9 replies · Started by Len on October 6, 2021

Viewing posts 1–10 of 10

How is a multiple column layout created for a custom taxonomy or custom post type archive with the Elements Content Block.

I cannot find any help for this. If a layout is created at 50% width, how will that repeat horizontally?

I have done a single column layout which works fine assigned to my CPT archives etc.

Thanks, LenW

Hi there,

the Block Element Content Template only replaces the content template in the post loop.
Today you still need to define the Column requirements in the Customizer > Layout > Blog.

However by default the columns options only work with standard post types.
To enable columns on a CPT you would need a little PHP:

add_filter( 'generate_blog_columns', function( $columns ) {
    if ( 'your_cpt_slug' === get_post_type() && ! is_singular() ) {
        return true;
    }

    return $columns;
} );

We're working on new archive grid options for a future update.

David

Thanks, this works - as long as the following is done:

The content template is set to full width as a design for the block, this code then reduces the width to that of the column.
If I start off with a 50% block in the content template editor, I end up with a 25% column if columns set to 2.

So template design a little tricky.

LenW

You can set the elements Editor Width in the sidebar settings - see here, in the example i have set it to 320px wide:

https://www.screencast.com/t/pKagnV1BS

This will allow you to create your design at a size that is representative of the front end display.

David, thanks for that suggestion, its a good help.
LenW

Glad yo be of help!

Hi David,
is there an update regarding this:

We’re working on new archive grid options for a future update.

or should we still stick to the filter

add_filter( 'generate_blog_columns', function( $columns ) {
    if ( 'your_cpt_slug' === get_post_type() && ! is_singular() ) {
        return true;
    }

    return $columns;
} );

Thanks
Dan

Hi Dan,

Currently this is still the one to use :)

Thanks Ying for the quick answer.

Dan

No problem :)

This archived topic is closed to new replies.