Archived topic
Custom Archive Layout
13 replies · Started by Martin on March 24, 2022
Hi there. I would like to use custom fields and layout in Archives (lists of custom posts).
Could you advise what location I need to put the Hook Element if that's the right approach or advise what is the best approach?
Thank you.
Hi Martin,
Are we talking about custom post type archive?
What kind of layout are you trying to achieve?
Let me know :)
It is for a custom post type archive but I want to customise the layout for all archives.
You can create block element - content template to create a custom look of archives:
https://docs.generatepress.com/article/block-element-content-template/
And here's a video demonstrate how to access custom fields in block element:
https://youtu.be/Ff7ikQ7Yw0w
The location of the element would be custom post type archive, for example, if your custom post type is movie, then you would see Movie Archive in the location dropdown.
Hi. I have the right location selected but can't find where to customise the contents of the archive loop.
I don't want to create a hero section. Not sure if I am using the correct wording here but it's the contents of the 'loop' that makes the list of posts I am looking to customise.
Thanks.
I figured it out...
generate_after_entry_title hook.
Although I am trying to disable thumbnail (featured image) in all archives.
Tried it by disabling the featured image in a layout element applied to 'all archives' but not managed to disable the featured image.
Select content templateas the element type, you should not need to select hook.
'Content Template' as an Element type?
Not seen that type of Element?
Here's the documentation of the block element - content template, there's also a demonstration video which should be helpful:
https://docs.generatepress.com/article/block-element-content-template/
Thanks. I’m a bit out of practice with GeneratePress so I have some learning to do with blocks. Although I’ve had premium for many years I’ve not built with it for a couple of years so I’m a bit rusty.
It's ok!
The block element - content template is still a new thing to a lot of GP users, it's normal if you haven't tried play with it!
It's a really powerful tool, hope you'll enjoy building site with it!
Just let us know if you run into problems :)
I created a simple block but can’t see how to apply it to my custom post type archives. Archives are not essential to the project I’m working on but it would be handy to figure out how to work with them in GP.
Make sure you watch the video carefully and understand how each step works.
Once the content template is built, select the custom post archive as location.
It should apply to your custom post archive page.