- This topic has 11 replies, 2 voices, and was last updated 5 years, 11 months ago by Tom.
-
AuthorPosts
-
May 2, 2018 at 7:23 am #565410Tanner
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
May 2, 2018 at 1:57 pm #565870TomLead DeveloperLead DeveloperHi 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 π
May 2, 2018 at 2:34 pm #565907TannerAwesome, 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
May 2, 2018 at 3:13 pm #565936TomLead DeveloperLead DeveloperIn that filter, the value can only be true or false. Do you want to be able to adjust the number of columns?
May 2, 2018 at 3:54 pm #565964TannerYeah, that would be awesome. I’m just still playing with things and to have that option would be great.
May 2, 2018 at 9:48 pm #566110TomLead DeveloperLead DeveloperCheck 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()
withis_category()
.Let me know if you need more info π
May 4, 2018 at 8:22 am #567402TannerHi,
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
May 4, 2018 at 8:25 pm #567893TomLead DeveloperLead DeveloperTry 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; }
May 5, 2018 at 6:36 am #568099TannerThat 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!
May 5, 2018 at 9:37 am #568284TomLead DeveloperLead DeveloperDoes 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
May 5, 2018 at 9:59 am #568300TannerOh, 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!
May 5, 2018 at 10:38 am #568323TomLead DeveloperLead DeveloperYou’re welcome π
-
AuthorPosts
- You must be logged in to reply to this topic.