- This topic has 7 replies, 3 voices, and was last updated 9 years, 1 month ago by Tom.
-
AuthorPosts
-
August 27, 2015 at 3:54 pm #132517Reuben
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/pEVSkyVNHowever, 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 π
August 27, 2015 at 11:07 pm #132571TomLead DeveloperLead DeveloperHi 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 π
August 28, 2015 at 9:23 am #132656ReubenI’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.
August 28, 2015 at 2:04 pm #132720bdbrownSorry, looking at the wrong page.
August 28, 2015 at 9:16 pm #132807ReubenI’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.
August 28, 2015 at 11:43 pm #132825TomLead DeveloperLead DeveloperGlad 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
August 29, 2015 at 12:50 am #132835ReubenYeah, 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!
August 29, 2015 at 10:06 am #132900TomLead DeveloperLead DeveloperDefinitely! π
-
AuthorPosts
- You must be logged in to reply to this topic.