Site logo

Archived topic

Disable masonry for other content types

3 replies · Started by Anonymous on March 9, 2015

Viewing posts 1–4 of 4

My client asked that I update their old site and they like the masonry look for the blog. The problem I'm facing is that they have other content types installed via the functions file. Masonry works great for the blog, but the other content types are displayed in masonry format as well.

Is there a way to force masonry to only work with blog posts? Or is there a way to disable masonry for other content types?

Thanks for all the great work you're doing!

Hi Eric,

I'm working on a way to easily add/remove masonry from categories/archives/custom post types in the next version of Blog/Premium - I'll update this thread if I manage to include it :)

Ok, I've included a new filter in Blog/Premium where you can choose where to enable/disable masonry with a PHP snippet.

Note: This will only work with Generate Blog 1.2.5 and GP Premium 1.2 and onward.

This example will enable Masonry only on the "Posts page" set in "Settings > Reading":

add_filter('generate_blog_masonry','generate_blog_enable_blog_masonry');
function generate_blog_enable_blog_masonry()
{
        // If we're on the posts page, enable masonry
	if ( is_home() )
		return 'true';
	
        // Otherwise, disable it
	return 'false';
}

This example would enable masonry within WooCommerce:

add_filter('generate_blog_masonry','generate_blog_enable_woocommerce_masonry');
function generate_blog_enable_woocommerce_masonry()
{
        // If we're in WooCommerce, enable masonry
	if ( is_woocommerce() )
		return 'true';
	
        // Otherwise, disable it
	return 'false';
}

All WordPress conditionals can be used: http://codex.wordpress.org/Conditional_Tags

Thanks for the kick in the butt to get this done!

Hi Tom, thanks so much for jumping on this. I really do appreciate all the great work you put in this theme!

Eric

This archived topic is closed to new replies.