[Support request] Applying Masonry to custom page template

Home Forums Support [Support request] Applying Masonry to custom page template

Home Forums Support Applying Masonry to custom page template

  • This topic has 6 replies, 3 voices, and was last updated 7 years ago by Tom.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #303945
    Peter

    Hi,

    I would like to apply the masonry layout to a custom page template. I found this old post from 2015 https://generatepress.com/forums/topic/masonry-issues-on-custom-page-template/, but it’s referencing a blog template that doesn’t seem to exist anymore. The pastebins are expired, too.

    Could you please explain what I need to do to get this working?

    Thanks
    Sibylle

    #304006
    Leo
    Staff
    Customer Support

    Hi Sibylle,

    Give this a shot: https://generatepress.com/forums/topic/enable-masonry-on-other-post-types/#post-111604

    Let me know if this helps.

    #304079
    Tom
    Lead Developer
    Lead Developer
    #305117
    Peter

    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

    #305120
    Leo
    Staff
    Customer Support

    The code looks good. Give it a shot.

    #305148
    Peter

    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?

    #305209
    Tom
    Lead Developer
    Lead Developer

    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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.