- This topic has 34 replies, 5 voices, and was last updated 7 years, 3 months ago by
Tom.
-
AuthorPosts
-
January 28, 2016 at 10:16 am #168605
Susanne
Hi There,
I have installed the portfolio post type plugin and the GP-premium plugin and would like to have my portfolio posts ( or any other custom post types i might create) display in masonry style.Do I have to create a archive-portfolio and single-portfolio template to do that or is there a way to ad a function. Right now only my regular posts display in masonry style.
Any input appreciated
Thanks
SusanneJanuary 31, 2016 at 12:25 pm #169403Susanne
Hello hello anyone out there?
February 1, 2016 at 1:36 pm #169706Susanne
ok just want to share that I have found a way to make it work, but only by changing the original plugin.
I opened the masonry.php file in generate-blog/functions and changed
this line (13)// If we're not dealing with posts, set it to false $masonry = ( 'post' == get_post_type() || is_search() ) ? $masonry : 'false'; to this // If we're not dealing with posts, set it to false $masonry = ( 'post' == get_post_type() || is_search() ) ? $masonry : 'true';
and voila, I now have masonry in all of my custom post types.
Of course I would like to do this in my child themes function file instead. That’s next on the agenda. will report back
February 5, 2016 at 11:03 pm #170834Tom
Lead DeveloperLead DeveloperHi Susanne,
I’m so sorry – I have no idea why I wasn’t notified of these posts. Time to look in my email error logs to see what’s going on.
Good news, the function you edited is filtered, meaning you can adjust it in your child theme.
For example:
add_filter( 'generate_blog_masonry','generate_adjust_masonry' ); function generate_adjust_masonry( $masonry ) { if ( 'your-post-type' == get_post_type() ) : return 'true'; endif; return $masonry; } add_filter( 'generate_blog_activate_masonry','generate_activate_posttype_masonry' ); function generate_activate_posttype_masonry() { $masonry = 'false'; if ( is_home() || is_archive() || is_search() || is_attachment() || is_tax() ) $masonry = 'true'; if ( 'your-post-type' == get_post_type() ) $masonry = 'true'; return $masonry; }
Give that a shot and let me know how it works π
-
This reply was modified 7 years, 10 months ago by
Tom.
-
This reply was modified 7 years, 10 months ago by
Tom.
-
This reply was modified 7 years, 9 months ago by
Tom.
-
This reply was modified 7 years, 9 months ago by
Tom.
-
This reply was modified 7 years, 9 months ago by
Tom.
-
This reply was modified 7 years, 9 months ago by
Tom.
-
This reply was modified 7 years, 9 months ago by
Tom.
February 8, 2016 at 12:16 pm #171371Susanne
Hi Tom,
Thanks so much for taking a look at this, I tried your filter in my child theme functions.php file.
This is what I put in:add_filter( 'generate_blog_masonry','generate_adjust_masonry' ); function generate_adjust_masonry() { if ( 'portfolio' == get_post_type() ) : return true; endif; if ( function_exists( 'generate_blog_get_masonry' ) ) : $masonry = generate_blog_get_masonry(); endif; return masonry; }
Unfortunately the entire site blanked out. This happens sometimes if I add something in functions that has some type of error in it. in firefox it says: The connection to the server was reset while the page was loading.
The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer’s network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.Any idea where the error might be?
February 8, 2016 at 11:57 pm #171455Tom
Lead DeveloperLead DeveloperSorry about that! Can you try the updated code?: https://generatepress.com/forums/topic/make-masonry-work-for-custom-post-types/#post-170834
February 9, 2016 at 5:02 am #171513Susanne
Hi Tom,
Thanks for the update, I see that you added the $ before masonry.
I used that code and got the same error message.
Any other ideas.? I am trying to learn all about filters and actions.Thanks
SusanneFebruary 9, 2016 at 11:19 am #171607Tom
Lead DeveloperLead DeveloperInteresting – do you have access to your server error_log file? If so, can you see if there’s a specific error in there?
If not, can you get your hosting tech support to take a look at the file?
February 9, 2016 at 12:44 pm #171652Susanne
Hi Tom, yes I am developing on Mamp, error log file says ( among other things):
2/9/16 3:29:52.446 PM Console[22121]: Failed to connect (_consoleX) outlet from (NSApplication) to (ConsoleX): missing setter or instance variableException Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00007fff5f3ffe5cFebruary 9, 2016 at 5:25 pm #171689Tom
Lead DeveloperLead DeveloperHmm, that doesn’t look like anything related to the code.
Do you have another site not on MAMP that you can test the code on?
February 9, 2016 at 9:06 pm #171708Tom
Lead DeveloperLead DeveloperAhh I found the problem.
Try the updated code: https://generatepress.com/forums/topic/make-masonry-work-for-custom-post-types/#post-170834
February 10, 2016 at 4:43 am #171745Susanne
Thanks so much for bearing with me Tom.
We are getting closer! the page is displaying now. However: the code just adds a class of “masonry-post” to the article, but none of the masonry classes to the containing elements.
Here is a live site, so you can take a look: http://www.sanneart.com/blog/
I have made the blog display in masonry.
My custom post type is portfolio.(link next to blog)
I added this to my child theme functions:add_filter( 'generate_blog_masonry','generate_adjust_masonry' ); function generate_adjust_masonry( $masonry ) { if ( 'portfolio' == get_post_type() ) : return true; endif; return $masonry; }
February 10, 2016 at 10:03 am #171849Tom
Lead DeveloperLead DeveloperThis is showing me a few things I need to clean up to make this process easier, so thanks for bearing with me! π
Can you try the updated code now?: https://generatepress.com/forums/topic/make-masonry-work-for-custom-post-types/#post-170834
February 10, 2016 at 10:27 am #171852Susanne
Thank You for doing this!
OK I uploaded the revised code. Still looks the sameFebruary 10, 2016 at 11:42 am #171867Tom
Lead DeveloperLead DeveloperWhat a mess this function is π I’ll be cleaning it up in the next update and will update this thread with the (much more simple) code you can use.
For now, try this: https://generatepress.com/forums/topic/make-masonry-work-for-custom-post-types/#post-170834
-
This reply was modified 7 years, 10 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.