Archived topic
Masonry for custom post types
13 replies · Started by Gerhard on November 12, 2017
Hi, I'm using the generate_blog_masonry filter to display certain pages with the masonry layout.
However, after upgrading to 1.5.2 it's not working anymore.
That's my code:
add_filter('generate_blog_masonry','generate_blog_enable_post_type_masonry');
$masonryPages = array(133,266,301);
function generate_blog_enable_post_type_masonry()
{
global $masonryPages;
if(in_array(get_the_ID(),$masonryPages) || is_home())
{
return 'true';
}
return $masonry;
}
Any help is greatly appreciated!
Hmm, that should be fine.
Which page isn't it working on?
Hello. I am having the same issue. Lost custom-post-type masonry when upgrading from GP Premium 1.4.3 to 1.5.2.
http://sbsginteriordesign.barkingdogweb.com/testimonials/
// add masonry to custom post type when enabled for blog
add_filter( 'generate_blog_masonry','sbsg_testimonials_masonry' );
function sbsg_testimonials_masonry( $masonry )
{
if ( is_post_type_archive( 'testimonials' ) ) :
return 'true';
endif;
return $masonry;
}
Thanks!
Hmm, I don't have a testimonials CPT, but I did just try this:
add_filter( 'generate_blog_masonry', 'tu_blog_masonry' );
function tu_blog_masonry( $masonry ) {
if ( is_home() ) {
return 'true';
}
return $masonry;
}
It worked as it should.
How are you adding the function? Child theme?
It's working for standard posts. But on the pages where I use a custom post type it looks like this: https://www.schlafgutmurmel.eu/termine/
However, on these pages I'm using page templates - I guess they are missing something, a class or some structure.
Yes, my function is in functions.php of a child theme.
Since you asked, I tested on a local install by moving the function into functions.php of the parent theme instead. Still no masonry for the custom post type.
Also as a test, I created a few standard posts and a blog page. The masonry for this works even without your function, because masonry is an option in the customizer.
Any chance you can send me temporary admin login details, or better yet duplicate your site into a sub-folder on your website using a plugin like Duplicator?
Thanks! I've cloned the site here: http://playground.barkingdogweb.com/
I will create a user for you and send it to support@generatepress.com
Perfect - thank you! Will figure out what's going on :)
I just released 1.5.3 which should fix this.
Let me know :)
As usual, you rule! Totally working now!
Awesome! Thanks for helping :)
Excellent, everything's working now, thanks a lot!
Great to hear! :)