Archived topic
Different blog views
5 replies · Started by WebbPlatsen on March 28, 2022
I want to use two different blog views. Which blog view to use depends on a Custom Post Type value each post have.
If I simplify this a lot it could be like following.
Blog view A:
Display 3 posts
Featured image
Title
Excerpt
Blog view B:
Display 1 post
Title
Featured image
Full page (All content)
Should I modify content.php in my child theme?
Hi there,
how are the two 'blog views' displayed ?
Can you share a URL to both of them ?
There is no website available right now.
This is how it could look like.
Main thing is to have different blog views.
----------------
Blog View A:
Post #1
Featured Image
Title
Excerpt
- - -
Post #2
Featured Image
Title
Excerpt
- - -
Post #3
Featured Image
Title
Excerpt
------------------------
Blog View B:
Post #1
Title
Featured Image
Content
Hi there,
Is Blog View A an archive? If so, you can use a Content Template - Block Element to achieve this: https://docs.generatepress.com/article/block-element-content-template/
For Blog View B, you can you a Page Hero - Block Element.
Both should work for Custom Post types.
Or, perhaps you’re referring to something else? Kindly let us know.
Hope this clarifies. :)
It's not an archive.
Right now Blog View B only display one post, but tomorrow it could be 5 posts.
I have just simplified these two views to show my basic needs looks like.
In each post, it will be some integration with other services. I will use custom code (PHP etc) to solve this.
I understand you want to solve this with Block Elements etc but there will a lot of custom behaviors.
I see. Thank you for clarifying.
If that’s the case, following the template hierarchy, you can create a archive-{post_type}.php based on archive.php for the archive pages of the Custom Post Type.
Reference: https://developer.wordpress.org/themes/template-files-section/custom-post-type-template-files/
Archive.php: https://github.com/tomusborne/generatepress/blob/master/archive.php
Hope this helps! :)