- This topic has 34 replies, 5 voices, and was last updated 8 years ago by Tom.
-
AuthorPosts
-
February 10, 2016 at 12:45 pm #171889Susanne
Well the plot definitely thickens:)
I used the latest code and don’t really see a change in the archive, however the single post now shows very small images. See it on my website)
This could be because i am using a plugin called jquery-masonry-image-gallery. It might conflict with the display of the gallery images.
However on my other local install I see the styling of the masonry applied to the archive. So it is targeting it.
Would it be possible to just create a custom archive-portfolio and put the masonry function in there?February 10, 2016 at 10:00 pm #171964TomLead DeveloperLead DeveloperI’m not seeing any single posts with small images? Do you have a direct link?
I’m confused as to why the filter isn’t targeting the post type.
Any chance you can send me temporary admin login details to support@generatepress.com?
February 11, 2016 at 3:34 am #172025Susanneyes i sent you a pw just now
here is the url for a sample page of tiny post. I think it makes a masonry tile out of the entire page which contains an image gallery with the masonry-image-gallery plugin activated. That’s why I think there might be a conflict. I just want the archive page to show masonry.February 11, 2016 at 7:31 pm #172209TomLead DeveloperLead DeveloperHa, well, this entire issue was a tiny mistake on my part.
I just adjusted the code and it seems to be working perfectly.
Let me know π
February 11, 2016 at 8:26 pm #172215Susannewoohoo!
You’re a freakin genius! Thanks so much!February 11, 2016 at 11:04 pm #172225TomLead DeveloperLead DeveloperYou’re very welcome – sorry that it took so long!
February 16, 2016 at 6:52 am #173111SusanneHi There,
Sorry to bug you again about this issue, but just one little follow up on this:
Apparently the function makes the single portfolio also have a masonry layout. which I only want in the archive
here is a screenshot from my local install
http://www.sanneart.com/single-portfolio.png
Can we fix that?
Thanks so muchFebruary 16, 2016 at 7:29 am #173121Susanneok update, I have found the solution: instead of saying
if ( 'portfolio' == get_post_type() ) $masonry = 'true';
I changed it to
if ( is_post_type_archive( 'portfolio' ) ) $masonry = 'true';
and that gives me the correct result!
February 16, 2016 at 10:49 am #173160TomLead DeveloperLead DeveloperNice! Thanks for posting the solution π
February 16, 2016 at 2:52 pm #173209Susanneso here is another development: I found that the first part of the filter works just fine by itself and has the added advantage to show the single post as it was intended.
Here is the URL http://www.sanneart.com/portfolio/ and the filter I usedadd_filter( 'generate_blog_masonry','generate_adjust_masonry' ); function generate_adjust_masonry( $masonry ) { if ( 'portfolio' == get_post_type() ) : return 'true'; endif; return $masonry; }
My last question ( I promise) is: how can I add the other post types to this as an array. I also have products and effects as post types? Thank you for your never-ending patience
February 16, 2016 at 4:41 pm #173226TomLead DeveloperLead DeveloperIn the new version I adjusted the generate_blog_masonry filter and removed the second one altogether. If you’d like to test it shoot me an email to support@generatepress.com π
More post types can simply be added to the function:
add_filter( 'generate_blog_masonry','generate_adjust_masonry' ); function generate_adjust_masonry( $masonry ) { if ( is_post_type_archive( 'portfolio' ) ) : return 'true'; endif; if ( is_post_type_archive( 'news' ) ) : return 'true'; endif; if ( is_post_type_archive( 'events' ) ) : return 'true'; endif; return $masonry; }
- This reply was modified 8 years, 5 months ago by Tom.
February 19, 2016 at 4:48 am #173824Susanneexcellent. You are the best. I will definitely like to test out the new theme as I have another site in development right now. Thank you!
February 23, 2016 at 10:22 am #174729Hans Christian SillerHey Tom,
I just had the same issue – making masonry work for custom posts… Superglad to see you have been working on this and are simplifying this in future versions!
I’ll be looking into the code you provided in more detail tomorrow. One suggestion though as you plan the changes for the next versions: one really awesome feature is the variable size of the masonry layout – ie. having the first post bigger, and manually assigning sizes (in masonry post width, and by setting a post to “featured” status). Can you think of a way of enabling that functionality (different sizes) for custom posts as well? That would be so *awesome*…
Ofc, we would then need to hack the editor to display the masonry post width options for custom posts as well. But I have no idea how to do that/if that’s easily possible.
February 23, 2016 at 9:45 pm #174854TomLead DeveloperLead DeveloperThat actually shouldn’t be too hard to do:
add_filter( 'generate_blog_masonry_metabox','generate_more_masonry_types' ); function generate_more_masonry_types() { return array( 'post', 'post-type-here', 'another-one' ); }
Let me know π
March 28, 2016 at 4:41 pm #182401Fabrizio LazzerettiHi Tom,
i’m stuck too with masonry and custom post type.
I’d like to have masonry on archive and search page, but not in the single article, which at the moment displays with the “medium” column.i’m using your code:
https://generatepress.com/forums/topic/make-masonry-work-for-custom-post-types/#post-170834thanks for any help.
-
AuthorPosts
- You must be logged in to reply to this topic.