[Support request] Switch off masonry on specific taxonomies

Home Forums Support [Support request] Switch off masonry on specific taxonomies

Home Forums Support Switch off masonry on specific taxonomies

Viewing 3 posts - 31 through 33 (of 33 total)
  • Author
    Posts
  • #688804
    Tom
    Lead Developer
    Lead Developer

    That’s what my code should do above: https://generatepress.com/forums/topic/switch-off-masonry-on-specific-taxonomies/page/2/#post-675589

    Basically, if you have columns and masonry enabled on your site, that code will *disable* masonry on the selected taxonomies.

    That will leave them with columns only (no masonry).

    #688950
    Hans

    I changed the code as you advised. The result is shown on the images above. I also tried it without hyphens using false – nothing changed. I moved the added action from my snippets to the functions.php of the child theme – no effect.

    I moved back to masonry to display three columns. When you change in line 33 of function.php in the child theme to false you will see the effect on page Ortsverein > Who is who (page 2).

    I already send the information how to investigate my site.

    #689087
    Tom
    Lead Developer
    Lead Developer

    Unfortunately I’m not able to log in and change any code – it’s against our forum policy (changing settings/code).

    However, I just tested the code.

    Here’s a category of mine with columns and masonry set in the Customizer: https://www.screencast.com/t/PUwIuqPXM

    Then I added this code to target my blog category. Of course, your code targets specific taxonomies.

    add_action( 'wp', function() {
        add_filter( 'generate_blog_masonry','tu_portfolio_masonry' );
    } );
    
    function tu_portfolio_masonry( $masonry ) {
        if ( is_category( 'blog' ) ) {
            return false;
        }
    
        return $masonry;
    }

    Now my blog category looks like this: https://www.screencast.com/t/ie3UNPaT

    So:

    1. Columns and masonry are turned on in the Customizer.

    2. I targeted my condition (category, in your cases taxonomies) and turned masonry off with the above code.

    3. Now my one category no longer has masonry, but columns remain.

    What happens if you target a single category like in my custom code? Does it work as intended?

    Let me know 🙂

Viewing 3 posts - 31 through 33 (of 33 total)
  • You must be logged in to reply to this topic.