Archived topic
Activate masonry only for categories
7 replies · Started by anamoore on April 5, 2015
Hello! I want to use/activate masonry but only for categories. I have 6 categories. Further more, I want to show only a single widget on those categories when masonry is activated. Can you please help me?
Coming soon!: http://generatepress.com/forums/topic/disable-masonry-for-other-content-types/#post-84372
As for showing widgets on specific categories/pages, this plugin may help: https://wordpress.org/plugins/display-widgets/
I can't figure out how to activate masonry for categories... plus not showing sidebars on them...
About the plugin, thank you very much!
Hi there,
The code snippets below will enable masonry on categories only, and remove the sidebars as well:
add_filter('generate_blog_masonry','generate_blog_enable_category_masonry');
function generate_blog_enable_category_masonry()
{
// If we're on a category, enable masonry
if ( is_category() )
return 'true';
// Otherwise, disable it
return 'false';
}
add_filter('generate_sidebar_layout','generate_category_sidebar');
function generate_category_sidebar($layout)
{
if ( is_category() ) :
return 'no-sidebar';
endif;
return $layout;
}
thank you very much, you are very kind!
You're welcome! :)
Hi Tom,
Thank you for this great theme.
add_filter('generate_blog_masonry','generate_blog_enable_category_masonry');
function generate_blog_enable_category_masonry()
{
// If we're on a category, enable masonry
if ( is_category() )
return 'true';
// Otherwise, disable it
return 'false';
}
add_filter('generate_sidebar_layout','generate_category_sidebar');
function generate_category_sidebar($layout)
{
if ( is_category() ) :
return 'no-sidebar';
endif;
return $layout;
}
where would I add this code? in which file?
I have the latest gp theme and premium installed.
I am trying to create a documentation / KB kind of site and would like the categories to be displayed in masonry but with fixed width / height (clickable).
3 boxes / columns like card layout to display my selected categories and a search bar in the middle of the page.
thanks
That code can be added with one of these methods:
Adding PHP: https://docs.generatepress.com/article/adding-php/
Code Snippets plugin is the easiest if you aren't using a child theme already.
Please open a new topic if you need further help with this as this topic is very old.
Thanks!