Archived topic
Switch off masonry on specific taxonomies
32 replies · Started by Hans on August 12, 2018
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).
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 :)