- This topic has 13 replies, 3 voices, and was last updated 4 years ago by
Ying.
-
AuthorPosts
-
May 31, 2022 at 2:16 pm #2239647
Leanne
I’m trying to set up an archive page for a custom post type and I’m lost.
I tried using a Block > Hook > before_content and within I had my term description (via Dynamic Content block) and a query loop (GenerateBlocks – beta) set to display how I wanted my queries to display. This caused it to repeat that block 24 times for every post I had, and then still had other content within it, I’m guessing from the archive template files within GeneratePress.
Then I tried a Block > Content Template, with a container set to 33%, an image and a heading (both GenerateBlocks using dynamic content). It brings in the correct content, but the columns are all 100% wide and there’s pagination, which I don’t want for these CPTs.
I’m running the betas of GenerateBlocks + Pro, and the latest version of GPP.
What I need to know is:
– How best to set up the framework/layout for an archive page for a custom post type
– How to style the query loop for this CPT and remove pagination from the CPTCan I create these with elements, or should I be working in my child theme files instead?
May 31, 2022 at 2:40 pm #2239656Ying
StaffCustomer Support– How best to set up the framework/layout for an archive page for a custom post type
If we are talking about the CPT archive page, NOT a static page, then using
block element - content templateis the way to go.Query loop block is used to add post loops to static pages.
The width you set in the content template won’t work, you’ll need this PHP filter to activate the columns for CPT, it will follow the columns number your set at customize > layout > blog.
https://docs.generatepress.com/article/using-columns-in-the-blog/#adding-columns-to-your-custom-post-type– How to style the query loop for this CPT and remove pagination from the CPT
If you are not adding CPT post loops to a static page, you won’t need query loop block.
June 1, 2022 at 7:21 am #2240284Leanne
I’ve got my columns working on my custom post type, I was able to get rid of pagination by setting up infinite scrolls within customizer.
My last issue is, how do I add a container around my content on the archive page for the CPT so I can set max-width, padding/margins, etc?
June 1, 2022 at 10:28 am #2240541Ying
StaffCustomer SupportCan you link me to your CPT archive page?
If it’s not using a specific archive template, it should follow the customizer options on spacing.
Let me know!
June 1, 2022 at 11:05 am #2240556Leanne
I added the URL to the private info.
With the customizer settings, it’s making the line under my breadcrumbs go to a max-width of 1200 rather than full width.
We’re likely going to have other full-width CTAs that need to go on this page as well. I added a test on at the bottom and it’s also being constrained to the width set in customizer on the archive page.
June 1, 2022 at 11:25 am #2240577Ying
StaffCustomer SupportWhat are you trying to achieve? Full width for the CPT archive? Or full width for the breadcrumbs?
June 1, 2022 at 11:54 am #2240593Leanne
The content between Collection: Kid’s Room down to above where the Testing block is needs to be a contained width. Everything else should be full width.
Looking at the source, everything contained within the div generate-columns-container that’s right after main class=”site-main” id=”main”> opens.
I guess css might be my best option then to set it?
June 1, 2022 at 3:32 pm #2240757Ying
StaffCustomer SupportIf you want a section to be full width, don’t insert them into the content container, insert them to
after_headerorbefore_footer.In order to make full width of the below elements:
1. Breadcrumb: block element type – hook , hook name:after_header.2. Archive page title and description: you can use a block element – page hero to replace the original one.
3. The testing block: block element type – hook, hook name:
before_footer.Here’s a hook visual guide: https://docs.generatepress.com/article/hooks-visual-guide/#posts-page
June 2, 2022 at 6:46 am #2241350Leanne
That works perfectly!!
One last question about archive pages. On the top level pages, like the 2 I shared, I want to only see the categories if there are sub-categories, but if there are no sub-categories, then it should show the posts for that category. Is there a way to do this with GeneratePress?
June 2, 2022 at 11:57 pm #2242071Fernando Customer Support
Hi Leanne,
To clarify, are you referring to the Breadcrumbs?: https://share.getcloudapp.com/yAu1on2X
If so, it would be best to reach out to the support of the plugin for the Breadcrumbs.
Hope this clarifies. If you’re referring to something else, kindly let us know. 🙂
June 3, 2022 at 6:21 am #2242379Leanne
No, not the breadcrumbs. Those are working fine.
I’m thinking more like how WooCommerce can show categories on the pages. I suspect this is outside the scope of your support though.
Because these are virtual exhibits, I need users to be able to drill down to the exhibit they want to view and then see the posts associated with that category. Right now the page is showing all posts from children categories under the parent.
June 3, 2022 at 11:06 am #2242729Ying
StaffCustomer SupportYou can give this PHP snippet a try:
https://generatepress.com/forums/topic/list-subcategories/#post-699132June 3, 2022 at 12:15 pm #2242800Leanne
I think that will work, or at least get me in the right direction.
Thank you so much for the assistance! I’m going to close the ticket now.
June 3, 2022 at 12:17 pm #2242804Ying
StaffCustomer SupportGlad to help 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.