[Resolved] Activate masonry only for categories

Home Forums Support [Resolved] Activate masonry only for categories

Home Forums Support Activate masonry only for categories

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #95752
    anamoore

    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?

    #95911
    Tom
    Lead Developer
    Lead Developer

    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/

    #97654
    anamoore

    I can’t figure out how to activate masonry for categories… plus not showing sidebars on them…

    About the plugin, thank you very much!

    #97685
    Tom
    Lead Developer
    Lead Developer

    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;
    }
    #97737
    anamoore

    thank you very much, you are very kind!

    #97761
    Tom
    Lead Developer
    Lead Developer

    You’re welcome! 🙂

    #1468068
    computerati

    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

    #1468102
    Leo
    Staff
    Customer Support

    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!

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