Archived topic
Layout Questions
11 replies · Started by Tanner on May 2, 2018
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
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 :)
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
In that filter, the value can only be true or false. Do you want to be able to adjust the number of columns?
Yeah, that would be awesome. I'm just still playing with things and to have that option would be great.
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 :)
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
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;
}
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!
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
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!
You're welcome :)