[Resolved] Layout questions – blog/archive featured posts on all paginated pages

Home Forums Support [Resolved] Layout questions – blog/archive featured posts on all paginated pages

Home Forums Support Layout questions – blog/archive featured posts on all paginated pages

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1576167
    Jem

    Hi GP crew. I’m trying to work to a design which is presenting a few problems, I wonder if you could point me in the right direction? I haven’t found anything here which helps directly.

    1) For only two category archives I need a single column layout with featured image on the left, but all other archives – the majority – need a 3 column grid with featured post, so I’ve set this as the default layout in the customizer and used CSS to make the featured post span 3 columns. All good. What’s the best way to apply a standard single column layout to the 2 other archives?

    2) All paginated pages in the 3 column archives need to be the same as the main page with the first post full width on each paginated page as I’m using Ad Inserter to place a full width ad under the first post. What’s the best way to achieve this? I’m currently using CSS which is working fine for the home page and its paginated pages but is it possible to add the featured-column class to the first post on each paginated page on both home page and all the archives that use the 3 column grid? It would make things much cleaner and simpler.

    Happy to provide more detail if needed but the site is local so I can’t provide a URL at this point. It’s very barebones, just using the customizer, CSS, a few functions to reposition a few things, with dummy content and minimal plugins aside from GP Premium and Ad Inserter.

    #1576294
    David
    Staff
    Customer Support

    Hi there,

    you can set blog layout options using the PHP Filter provided here:

    https://docs.generatepress.com/article/option_generate_blog_settings/

    And to change the Blog Columns you would use this snippet:

    add_filter( 'generate_blog_columns','tu_portfolio_columns' );
    function tu_portfolio_columns( $columns ) {
        if ( is_category()  ) {
            return false;
        }
    
        return $columns;
    }
    #1576560
    Jem

    Hi David, many thanks for that.

    Unfortunately I have no idea how to use that filter to set the first post on every paginated archive page to be a featured post. If it allows the class .featured-column to be applied, could you explain how?

    I’ll see what I can do regarding the blog columns.

    #1576744
    Jem

    OK, I must be getting something wrong with the filter, or it doesn’t do what I need. Here’s how I set it up, theoretically targeting all archives but the 2 listed, and replicating the other customizer settings for the blog:

    add_filter( 'option_generate_blog_settings', 'jc_custom_archive_page_settings' );
    function jc_custom_archive_page_settings( $options ) {
    	if ( is_paged() && ! is_category( array( 'white-papers', 'ebooks' ) ) ) {
    	$options['read_more_button'] = true;
    	$options['date'] = false;
    	$options['categories'] = true;
    	$options['tags'] = false;
    	$options['comments'] = false;
            $options['infinite_scroll'] = false;
    	$options['infinite_scroll_button'] = false;
    	$options['masonry_load_more'] = 'More search results';
    	$options['post_image'] = true;
    	$options['post_image_position'] = 'post-image-above-header';
    	$options['post_image_alignment'] = 'post-image-aligned-center';
    	$options['column_layout'] = true;
    	$options['featured_column'] = true;
    	$options['masonry'] = false;
        }
      
        return $options;
    }

    This doesn’t add the featured-column class to the top post on paged pages, which is all I’d like to do. Does this filter option only add that class to the most recent post in the entire archive i.e. the first post on the first page? If so it’s redundant here as that’s happening already. I need it to target whichever post is most recent on a given paged page, if that’s even possible? If not I’ll stick to CSS for this.

    I successfully got the 2 archives into a single column layout, thank you, they just need some CSS now, which I’m happy to sort out.

    #1576884
    Leo
    Staff
    Customer Support

    Any chance you can link us to the site in question?

    #1577256
    Jem

    Hi, sorry, no, as I say its local just now though hopefuly it’ll be on a staging server pretty soon.

    At this point all I’m really wanting know is if it’s possible to add the featured-column class (or any other unique class) as described above – so that it’s applied to the first post on any paged archive page, and not just the most recent post in the entire archive/the first page. I have the layout working as needed using CSS but was hoping to be able to simplify things with this.

    If it’s not a straightforward thing I can live without it and this thread can be closed, no worries.

    #1577749
    Leo
    Staff
    Customer Support
    #1577891
    Jem

    Thanks Leo, I’m already doing something along those lines. I searched here for this too and never found that thread. Thanks again.

    #1578021
    Leo
    Staff
    Customer Support

    Not an easy one to find ๐Ÿ™‚

    Glad to help ๐Ÿ™‚

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