Site logo

[Support request] Columns only on one category archive page

Home Forums Support [Support request] Columns only on one category archive page

Home Forums Support Columns only on one category archive page

Viewing 15 posts - 1 through 15 (of 32 total)
  • Author
    Posts
  • #2466621
    Manuel

    Hi team,

    I would like to have, only on one category page 3 columns (without excerpt just title), but not on the archive page.
    I want to let my archive page without columns.
    My archive page is this one: https://manuelmeszarovits.com/journal/
    My category page is this one (where I want the columns): https://manuelmeszarovits.com/category/photo-of-the-day/

    I was looking for that on the forum but didn’t find a solution.
    If I enable Columns in Customizer > Layout > Blog –> Columns it make it for all archive page!

    So what is the solution?
    In advance thank you for your time,
    Manuel

    #2466632
    Fernando
    Customer Support

    Hi Manuel,

    To clarify, are you looking to alter the column number for specific archive pages?

    If so, you’ll need a PHP snippet.

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

    So for instance, you can try adding:

    add_filter( 'generate_blog_get_column_count','tu_search_column_count' );
    function tu_search_column_count( $count ) {
        if ( is_category('photo-of-the-day') ) {
            return 33;
        }
    
        return $count;
    }

    Replace ‘photo-of-the-day’ of the day with the archive slug, and 33 with your desired column length. 33 produces a 3-column layout.

    #2467954
    Manuel

    Hi Fernando!
    Sorry I didn’t get the notification of your answer.
    Yes I’m looking for 3 columns on the archive page https://manuelmeszarovits.com/category/photo-of-the-day/

    So I put the PHP snippet in the functions.php but nothing happened.

    Thanks,
    Manuel

    #2468075
    David
    Staff
    Customer Support

    Hi there,

    the columns need to be active for that function to work.
    So instead.

    1. remove the function Fernando provided.
    2. activate the Blog Columns in Customizer > Layout > Blog
    3. add this PHP Snippet to disable the columns everywhere except for your category

    
    add_filter( 'option_generate_blog_settings', function( $options ) {
        if ( !is_category('photo-of-the-day') ) {
    	$options['column_layout'] = false;
        }
        return $options;
    });
    #2468140
    Manuel

    Working very good David!
    But two more thing:
    – How to don’t have excerpt on category’photo-of-the-day’?
    – How to have bigger photo who keep all the 1200px of the container?
    Thanks,
    Manuel

    #2468213
    David
    Staff
    Customer Support

    For the excerpt:

    
    add_filter( 'excerpt_length','lh_custom_category_excerpt_length', 1000 );
    function lh_custom_category_excerpt_length( $length ) 
    {
        if ( is_category('photo-of-the-day') ) {
            return 0;
        } 
        return $length;
    }

    For the image – do you want each post to have a larger image so it fills its column ?

    #2468359
    Manuel

    Working good David!
    Just I still have “…Read more”. I want only the title of the post.
    Yes I want the image to fill all the container on the 3 columns.
    Thanks David,
    Manuel

    #2468627
    Ying
    Staff
    Customer Support

    Hi Manuel,

    Can you try adding this PHP snippet to remove the “read more”?

    add_action('wp', function() {
        if (is_category('5')) {
            add_filter( 'generate_excerpt_more_output', function() {
                return '';
    	} );
        }
    });

    And this CSS for the images:

    .archive.category-5 .post-image img {
        width: 100%;
    }
    #2468661
    Manuel

    Working perfectly, all two, Ying!
    Last question and after I stop to bother you 😉
    On this category, ID 5, I want to hide the pagination on every single post (like on this one: https://manuelmeszarovits.com/african-woman-walking-bush/), because the pagination is not only the category but all the archive?
    In advance thank you so much,
    Manuel

    #2468686
    Ying
    Staff
    Customer Support

    Do you mean the post navigation at the bottom of the post?
    https://www.screencast.com/t/g85QGzZ1

    If so, it’s using a block element - post navigation:https://docs.generatepress.com/article/block-element-post-navigation/

    1. You should be able to find it at appearance > elements.

    2. If you want to remove it from this category, go to edit that element, add post category > this categoryto the exclusion list of the element’s location.

    If you want to create a new post navigation within the same category, do the above 2 steps, then:
    3. Copy all the content from this element to a new block element. Here’s a video that shows how to do that on page editor:
    https://youtube.com/watch?v=CsT1UOzZUgI&si=EnSIkaIECMiOmarE

    4. Toggle the in the same term option:https://docs.generatepress.com/article/block-element-post-navigation/#in-same-term

    5 .Choose Post navigation as element type, choose the same hook as the original element, add post category > this category as the location.

    Let me know 🙂

    #2468970
    Manuel

    Thank you so much Ying. I didn’t dare to ask you for the navigation for the category.

    So I made everything but the result is not good with repetition of the pagination for the archive but not for the category. Have a look: https://manuelmeszarovits.com/african-woman-walking-bush
    I join you a screen print of the element page to see what I made: https://manuelmeszarovits.com/wp-content/uploads/2022/12/screen-print-element-pagination-pic-day.jpg

    Thanks,
    Manuel

    #2468982
    Manuel

    I exclude now from the element archive pagination to don’t repeat but I still have the archive pagination instead the pic of day pagination!

    #2468985
    Fernando
    Customer Support

    Hi Manuel,

    For clarification, what repetition are you referring to? Can you take a screenshot of this issue as well?

    #2468989
    Manuel

    Thanks for your quick reply Fernando.
    I don’t have any more the repetition because from the element page archive pagination I excluded the pic of day category.
    So the problem now is that instead to have the pagination of pic of day I have the pagination of archive.
    I sent you a screen of the element page pagination pic of day to see what I made wrong.

    #2468996
    Fernando
    Customer Support

    Can you expound a bit more on the issue? Are you referring to a Block Element not appearing as it should on a page? Or, are you referring to the pagination in itself not working as you expect?

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