Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Tiling an Archive

  • Sorry, I’m having trouble finding documentation on this. Can you tell me how to arrange an archive as a grid of posts instead of each one being on their own line? Currently, I have the following:

    — Layout element that disables sidebars for the post type archive
    — Block element that formats the display of the individual post inside the archive

    The customer has requested we tile the archive (it will be a three-column grid with just the featured image hyperlinked to the post), but I cannot figure out how to make this setting. I can only modify the individual post item, not the archive page itself.

    Thanks for any help.

  • Hi there,

    1. go to Appearance > GeneratePress and activate the Blog modules
    2. go to Customizer > Layout > Blog, and activate the Columns option.

  • Thanks. Is there a way to do this only for one post type? I have a custom post type called “Sponsors” that I would like to have laid out in columns. Also, I noticed it makes the first post in the archive big and the rest in columns. Is there a way to make them all the same?

    — Aaron

  • Hi Aaron,

    Yes, it’s possible.

    1. Keep the columns enabled in the Customizer.

    2. Un-toggle “Make first post featured” in Customize > Layout > Blog.

    3. Add this snippet:

    add_filter( 'option_generate_blog_settings', function( $options ) {
        if ( !('CPT_SLUG' === get_post_type() && ! is_singular()) ) {
    	$options['column_layout'] = false;
        }
        return $options;
    });

    Replace CPT_SLUG in the code with the slug of your CPT.

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

  • Thanks. Something strange is happening now, though. Suddenly when I enable columns, it makes all archives EXCEPT the sponsors archive into a grid (even without adding the custom code snippet, so I know it’s not the custom code).

    Is there any reason you can think of it would be doing this?

  • The GP Blog Columns only applies to the Post posttype by default.
    So you can disable those.
    And use this snippet to enable the columns just on the CPT ( make sure the slug is correct ):

    
    add_filter( 'option_generate_blog_settings', function( $options ) {
        if ( !('sponsors' === get_post_type() && ! is_singular()) ) {
    	$options['column_layout'] = true;
        }
        return $options;
    });
    
  • Unfortunately it does not seem to be having the desired effect. It was actually causing all other post types except ‘sponsors’ to have a column format, so I revised the code as follows:

    add_filter( 'option_generate_blog_settings', function( $options ) {
        if ( 'sponsors' === get_post_type() && ! is_singular() ) {
    		$options['column_layout'] = true;
        }
        return $options;
    });

    Now, none of the post types are displaying as columns, including the ‘sponsors’ post type. I’ve put test text inside the conditional section of the code and can see it’s running, but still no columns. Do we need to set the number of columns? Preferably, it would be set to 4. If so, can you let me know the code that’s used?

  • Hi there,

    1. Disable the column set in the customizer > layout > blog.

    2. Remove previous PHP code, add this one instead:

    add_filter( 'generate_blog_columns', function( $columns ) {
        if ( 'sponsors' === get_post_type() && ! is_singular() ) {
            return true;
        }
    
        return $columns;
    } );
    
    add_filter( 'generate_blog_get_column_count','tu_search_column_count' );
    function tu_search_column_count( $count ) {
        if ( 'sponsors' === get_post_type() && ! is_singular() ) {
            return 25;
        }
    
        return $count;
    }
  • That did the trick! Thanks.

  • You are welcome   🙂

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.