Site logo

Archived topic

Applying Masonry to custom page template

6 replies · Started by Peter on April 10, 2017

Viewing posts 1–7 of 7

Thanks for your suggestions.

Tom, would this work on page templates as well as posts, i.e. like so:

add_filter( 'generate_blog_masonry','tu_portfolio_masonry' );
function tu_portfolio_masonry( $masonry )
{
if ( is_page_template('my-custom-template.php') ) :
return 'true';
endif;

return $masonry;
}

And what would I have to add to the page template itself? This is what I have https://pastebin.com/bB6r2PMd

The code looks good. Give it a shot.

Thanks, Leo. I seem to have managed it by removing my div around the article loop in the template and adding the classes masonry-post to the article and inside-article to the inner div.

Is that the correct way to do it or should that be handled by the JS?

That function should do all of that for you as long as the main markup in your page template is the same as regular pages.

This archived topic is closed to new replies.