Using Masonry in the Blog

Note: These options require the Blog add-on in GP Premium.

We can enable masonry in our blog by going to Customize > Blog > Masonry.

These settings apply to the post post type by default, and will display on your blog index, archives, tags and categories.

  • Masonry – enable or disable masonry.
  • Masonry Block Width – all of the posts
    • Small – 1/3 columns
    • Medium – 2/3 columns
    • Large – 1 column
  • Masonry Most Recent Width – the most recent post.
    • Small – 1/3 columns
    • Medium – 2/3 columns
    • Large – 1 column
  • Masonry Load More Text – the text in the Load More button
  • Masonry Loading Text – the text that displays when your posts are loading

Adding masonry to your custom post type

By default, masonry only applies to the post post type. However, you can add masonry to your custom post type using the filter:

add_filter( 'generate_blog_masonry','tu_portfolio_masonry' );
function tu_portfolio_masonry( $masonry )
{
    if ( is_post_type_archive( 'portfolio' ) ) :
        return 'true';
    endif;

    return $masonry;
}

You can use this filter to enable or disable masonry under any conditions you need by using the WordPress conditional tags.

Learn how to add PHP here.