Site logo

Archived topic

Switch off masonry on specific taxonomies

32 replies · Started by Hans on August 12, 2018

Viewing posts 31–33 of 33

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.

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 :)

This archived topic is closed to new replies.