[Resolved] Masonry issues on custom page template

Home Forums Support [Resolved] Masonry issues on custom page template

Home Forums Support Masonry issues on custom page template

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #132517
    Reuben

    Hi there,

    I am having issues with the masonry failing to work properly on a custom page template.

    First things first, how do I get the masonry filter to detect a custom page template? I tried is_page or is_page_template but it doesn’t work. In the end, I’m resorting to a blanket return true; for now.

    Next, this is my page template: http://pastebin.com/w6C4yn2v
    And the content template where the page template pulls from for the loop: http://pastebin.com/pEVSkyVN

    However, what I end up with is this: https://www.buyfromwhere.com/database-all/
    As compared to normal archive pages, which show up properly: https://www.buyfromwhere.com/database/retailers/

    I looked through the source a little and it seems that for a custom page template, it’s somehow missing some critical CSS.

    Is there any way to solve this? Thanks Tom πŸ™‚

    #132571
    Tom
    Lead Developer
    Lead Developer

    Hi Reuben,

    What makes that page template different than a regular category or archive template?

    As for the displaying weird – is the main issue the sidebar showing up below the content? If so, that usually happens when there’s an open HTML tag which hasn’t been closed properly. Try checking all of your opening elements for their closing element.

    Let me know πŸ™‚

    #132656
    Reuben

    I’ve checked and they seem to be all closed. Disabling masonry displays everything they were supposed to be.

    It seems to be that the theme is not passing some attributes over for the custom page template, and I’ve no idea why. FOr example, there’s no width set, etc.

    I use the exact same content template for the custom page template and the archive pages. The only diffeerence between the custom page and archive template is the WP_Query.

    #132720
    bdbrown

    Sorry, looking at the wrong page.

    #132807
    Reuben

    I’ve found a solution: you must add in the following code as well:

    add_filter('generate_blog_activate_masonry','generate_blog_activate_blog_masonry');
    function generate_blog_activate_blog_masonry()
    {
    
    return "true"; 
    
    	
    
    }
    

    By the way, is there any way to get is_page_template to work properly within the loop? I can’t use conditionals right now because outside the loop, is_page_template returns true, but inside the loop, it turns false and the whole masonry thing screws up.

    #132825
    Tom
    Lead Developer
    Lead Developer

    Glad you found that filter!

    I’m pretty sure you can’t – more info here: https://codex.wordpress.org/Function_Reference/is_page_template#Cannot_Be_Used_Inside_The_Loop

    #132835
    Reuben

    Yeah, I figured as well. So I guess it’s either all or nothing for my Masonry pages πŸ™

    Still, it’s nice to know how to get my page templates to behave like normal archive pages!

    #132900
    Tom
    Lead Developer
    Lead Developer

    Definitely! πŸ™‚

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