Black Friday sale! Get up to 25% off GP Premium! Learn more ➝

[Support request] Issue with web-stories archive page

Home Forums Support [Support request] Issue with web-stories archive page

Home Forums Support Issue with web-stories archive page

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #2265067
    Hilton

    Hello, I use the web-stories plugin and I’d like to know how can I customize web-story archive page so ir can display 3 columns with pagination, as this one https://bit.ly/3bua7LM . This is how my current page is looking like https://bit.ly/39R39An . Thanks

    #2265275
    Fernando
    Customer Support

    Hi Hilton,

    You’ll need a PHP snippet to add columns to your CPT: https://docs.generatepress.com/article/using-columns-in-the-blog/#adding-columns-to-your-custom-post-type

    There’s also a code here to change the number of columns.

    So, yours would be:

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

    and

    add_filter( 'generate_blog_get_column_count','tu_search_column_count' );
    function tu_search_column_count( $count ) {
       if ( 'CPT_SLUG' === get_post_type() && ! is_singular() ) {
            return 33;
        }
    
        return $count;
    }

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

    Hope this helps!

    #2269127
    Hilton

    Hello, I don’t know if you’ve seen the web stories archives page, which is this one https://bit.ly/39R39An . I need a specific function for that archives page, which in this case is mywebsite.com/web-stories . Your function doesn’t seem to be specific to this page.

    #2269150
    David
    Staff
    Customer Support
    #2269168
    Hilton

    Hi David,

    Looks like it was a great start. But first of all, this web-stories archives page is the only one on the site that will be using columns, so I believe it needs an add-on to this function. Another thing is that I would like the web-stories archive page to display only the stories, in 3 columns, and not the same format of the other archive pages, where the image, title and excerpt appear.

    https://bit.ly/3OOJY8Y

    Thanks!

    #2269177
    David
    Staff
    Customer Support

    This doc explains how to set the columns:

    https://docs.generatepress.com/article/using-columns-in-the-blog/#changing-the-number-of-columns

    If you just want the ‘content’ to be displayed then the simplest approach would be to use a Block Element – Content Template:

    https://docs.generatepress.com/article/block-element-content-template/

    For your template, it sounds like you just want to add a GP Dynamic Content block to display the excerpt.

    #2269368
    Hilton

    Hi David,

    That is great! My page looks exactly the way I expected https://bit.ly/3AgFl3m

    I added the following functions, hope it help other users:

    add_filter( 'generate_blog_columns', function( $columns ) {
        if ( ! is_singular() && 'web-story' === get_post_type() ) {
            $columns = true;
        }
    
        return $columns;
    } );
    add_filter( 'generate_blog_get_column_count','tu_search_column_count' );
    function tu_search_column_count( $count ) {
        if ( ! is_singular() && 'web-story' ) {
            return 33;
        }
    
        return $count;
    }
    add_filter( 'get_the_archive_title', function ( $title ) {
        if ( 'web-story' === get_post_type() ) {
            $title = 'Web Stories';
        }
    	return $title;
    },50);
    #2269380
    Hilton

    David,

    Just one more question, if I wanted to add the same layout to another custom post type named “video”, how can I change the function above to make it working for both (“web-stories” and “video”). Should I use an array?

    Thanks

    #2270073
    David
    Staff
    Customer Support

    Awesome – yeah you can use an array fro example:

    add_filter( 'generate_blog_columns', function( $columns ) {
        $post_types = array(
            'web-story',
            'video'
        );
        if ( ! is_singular() && in_array( get_post_type(), $post_types )  ) {
            $columns = true;
        }
    
        return $columns;
    } );
    
    
    #2270253
    Hilton

    Thanks David! You are the best!!

    #2270270
    David
    Staff
    Customer Support

    Glad to be of help

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