[Resolved] Layout Questions

Home Forums Support [Resolved] Layout Questions

Home Forums Support Layout Questions

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #565410
    Tanner

    Hi,

    New GP Premium user and relatively new to WordPress.

    I have a couple questions regarding my site’s layout and it may involve some CSS help.

    First, I’m using Categories to separate my Nav Bar topics. I’m wondering how to remove the Category container at the top of each page?

    Second, on my Home page, I’m displaying my blog content in 2 columns with a featured post at the top. This is great, but I’d like to list the categorized posts in a single column when users click on the Nav Bar to sort by topic.

    Does this make sense? Sorry if I’m not using the right terminology. Pretty new to this.

    Many thanks!

    Tanner

    #565870
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    1. Add this CSS:

    .category .page-header {
        display: none;
    }

    2. Add this function:

    add_filter( 'generate_blog_columns', 'tu_category_columns' );
    function tu_category_columns( $columns ) {
        if ( is_category() ) {
            return false;
        }
    
        return $columns;
    }

    Adding CSS: https://docs.generatepress.com/article/adding-css/
    Adding PHP: https://docs.generatepress.com/article/adding-php/

    Let me know πŸ™‚

    #565907
    Tanner

    Awesome, both worked. I used the Additional CSS in the Customizer for the CSS, and used the Code Snippets plugin for the PHP function.

    A question regarding the latter, if I wanted to change the column value, how would I go about altering the above code? I’m guessing it has something to do with the $ symbol but am not sure.

    Many thanks, your customer service is excellent!

    Tanner

    #565936
    Tom
    Lead Developer
    Lead Developer

    In that filter, the value can only be true or false. Do you want to be able to adjust the number of columns?

    #565964
    Tanner

    Yeah, that would be awesome. I’m just still playing with things and to have that option would be great.

    #566110
    Tom
    Lead Developer
    Lead Developer

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

    In the example, you would replace is_search() with is_category().

    Let me know if you need more info πŸ™‚

    #567402
    Tanner

    Hi,

    I see how that function works. I think I’d like to display the category posts in three columns, so return 33. What’s happening though is it’s keeping the featured post from the Layout-Blog settings. Is there a way to disable that? Thanks!

    Tanner

    #567893
    Tom
    Lead Developer
    Lead Developer

    Try this:

    add_filter( 'option_generate_blog_settings', 'tu_disable_category_featured' );
    function tu_disable_category_featured( $options ) {
        if ( is_category() ) {
            $options['featured_column'] = false;
        }
    
        return $options;
    }
    #568099
    Tanner

    That worked to disable the featured post. How would I adjust that snippet to return various numbers of columns? Do I change the $ symbol? Like 33 for 3 columns, 50 for 2, etc.? Thanks!

    #568284
    Tom
    Lead Developer
    Lead Developer

    Does the function I linked to above not work when it comes to changing the number of columns?: https://generatepress.com/forums/topic/layout-questions/#post-566110

    #568300
    Tanner

    Oh, I see – my bad. I wasn’t using both functions – I thought the function to remove the featured post was meant to replace the previous one. Using both snippets works perfectly though. Thanks!

    #568323
    Tom
    Lead Developer
    Lead Developer

    You’re welcome πŸ™‚

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