[Resolved] How to display CPT archive to match default Generatepress layout (masonry)
This support ticket is created 3 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I use the pro Generatepress theme (with GP Premium plugin). This theme allows the display of the post archive page as a two-column masonry grid. I've created a few custom post types and I want them to follow the same archive layout as posts.
Is there any documentation that you are following?
I'm using the code from this page: hidden link
I added the following code via Toolset's Custom Code Snippets feature:
//////////////
add_filter( 'generate_blog_masonry','qa_faqs_masonry' );
function qa_faqs_masonry( $columns ) {
if ( is_post_type_archive( 'FAQ' ) ) {
return true;
}
return $masonry;
}
////////////
My CPT Name: FAQ
My CPT slug: qa_faqs
Is there a similar example that we can see?
This is the masonry layout for normal posts: hidden link
Any time an FAQ post type appears in the archive list, it messes up the layout.
What is the link to your site?
This is the archive for my FAQ cpt:
hidden link
The posts should be displayed in a two column masonry grid. What am I missing?
Thank you for contacting us and I'd be happy to assist.
I've noticed a couple of points about the snippet that you've shared:
1. In the function's name (line# 2), it is using the "$columns" parameter, but at the end (line# 7), it is returning the "$masonry" variable, which is not defined anywhere. They both should be the same variables.
3. The conditional check for the "is_post_type_archive( 'qa_faqs' )" would only apply to the FAQ post type's archive page, which is at:
{yourwebsite.com}/qa_faqs/
The page that you're trying to target is the category archive page for the term "FAQ":
{yourwebsite.com}/category/faq/