- This topic has 7 replies, 2 voices, and was last updated 7 years, 2 months ago by Tom.
-
AuthorPosts
-
June 17, 2016 at 10:03 am #202791Alvaro
Hi,
I need a blog columns layout, using the Blog add-on, different on one category archive page. Is there a hook for that?
I know I can change the sidebar layout by category using GP hooks and conditionals (https://generatepress.com/knowledgebase/choosing-sidebar-layouts/) but I don’t know how to have different columns # in a blog column layout for a specific category.
I need one category to have 3 columns and no sidebar, I need other to have 2 columns and the right sidebar.
Thanks.
June 18, 2016 at 12:07 am #202898TomLead DeveloperLead DeveloperHi there,
There’s a filter to enable/disable columns all together just like the sidebar layout, but there’s currently no filter to choose how many columns using a filter.
I’ve added this to the list of improvements for the next update – I’ll update this thread once I have it implemented.
June 18, 2016 at 3:29 am #202915AlvaroSo, the only imediate way is to have a category specific archive template, right?
Thanks Tom.
June 18, 2016 at 9:55 am #202965TomLead DeveloperLead DeveloperI just added the filter, so in GP Premium 1.2.87 you’ll be able to do this:
add_filter( 'generate_blog_get_column_count','generate_custom_column_count' ); function generate_custom_column_count() { if ( is_category( 'Whatever' ) ) return 3; if ( is_category( 'Example' ) ) return 2; // Or else, return the default return $count; }
If you’d like to try it before I release it just shoot me an email 🙂
February 3, 2017 at 3:41 am #273746AlvaroHi Tom,
I’m sure this was working before but now I’m not getting the number of columns. It seems that, when I use this filter, the generated class is
grid-X
, withX
being the number of columns instead of the matching grid class, it should begrid-33
for 3 columns,grid-25
for 4 columns, etc., right?I solved it by changing the filter code to the actual class count, like this:
/** * Set the page columns per category * */ add_filter( 'generate_blog_get_column_count','generate_custom_column_count' ); function generate_custom_column_count() { if ( is_category( 'noticias' ) ) return 25; if ( is_category( 'atas' ) ) return 100; // Or else, return the default return $count; }
but I’m pretty sure this was not intended. Was it?
Thanks.
Álvaro
February 3, 2017 at 11:29 am #273905TomLead DeveloperLead DeveloperYea, that’s the intended use, although I agree it’s not very intuitive. I just updated the documentation here: https://docs.generatepress.com/article/using-columns-in-the-blog/#changing-the-number-of-columns
Thanks for pointing that out 🙂
February 6, 2017 at 2:22 am #274922AlvaroOK. Thanks Tom.
February 6, 2017 at 9:11 am #275115TomLead DeveloperLead DeveloperNo problem 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.