Archived topic
Custom Category Page with Generate Blocks or something else
9 replies · Started by Scott on November 25, 2022
Hi there,
I want to make a custom Parent Category page by inserting GenerateBlocks above the ascending posts that live within that category. What's the best way to do that?
Some background:
My goal is to have a site structure with permalinks as follows:
site.com/category/sub-category/post/
Example with random category and subcategory names:
site.com/recipes/vegan/how-to-make-vegan-ice-cream
site.com/recipes/vegan/baked-vegan-lasagna
And I want to be able to design the Parent Category (i.e. site.com/category or site.com/recipes/) with a block from GenerateBlocks at the top of the Parent Category page highlighting the best subcategories - e.g. vegan, vegetarian, bbq, cocktails, etc. Specifically, I'm wanting to use this block from GenerateBlocks. However, I wasn't able to find a way to do this with traditional post categories.
As a workaround, I then created a regular WordPress "Page" and was able to customize that as I wanted with Gutenberg and GenerateBlocks. Easy enough. I set the slug of the Page also to "recipes" and published it. But it's effectively completely detached from the Post Categories and Subcategories, and the site.com/recipes goes to the normal parent category, not the "Page" slug. Because the hierarchy of Post Categories is taking priority.
And I cannot find a way to set the permalink structure such that the "Page" can be the parent category, with regular "Post Subcategories" living underneath.
I hope what I'm trying to do and this explanation make sense. If not, I'm happy to make a Loom video.
Hi there,
Just so i am 100% clear ( which for me can take some doing lol ), if i view this Parent Category page, and i split it into top and bottom sections, i would see:
Top section: a list / grid of sub categories
Bottom section: Latest post from the Parent Category
Is that correct ?
Exactly! And if possible, the top section would use the block from GenerateBlocks where I could add some text beneath each item in the grid, maybe a button to view all articles in the subcategory, etc.
Adding to the above, the main reason I want to use Gutenberg editor/design on the Post Category Archive page is to maintain a good site structure with permalinks. e.g. site.com/category/sub-category/post/
Rather than have an isolated "category" page at site.com/page which then links to subcategories or posts which aren't on the same subdirectory path.
I have done similar pages using Generate Blocks and the WP Show Posts plugin.
For the posts sections of the page I create a container with Generate blocks and put a WP Show Posts shortcode in the container with the filters I need for the post content.
Thanks, Mike! How does the permalink structure work for that? If I understand correctly, that might be the workaround I tried with Pages but it doesn't follow the permalink structure I'm looking for.
As a workaround, I then created a regular WordPress “Page” and was able to customize that as I wanted with Gutenberg and GenerateBlocks. Easy enough. I set the slug of the Page also to “recipes” and published it. But it’s effectively completely detached from the Post Categories and Subcategories, and the site.com/recipes goes to the normal parent category, not the “Page” slug. Because the hierarchy of Post Categories is taking priority.
And I cannot find a way to set the permalink structure such that the “Page” can be the parent category, with regular “Post Subcategories” living underneath.
My goal is to have a site structure with permalinks as follows:
site.com/category/sub-category/post/
Did some more Googling, and I found that Elementaor allows customization to the Archive Category pages. So that will be my backup plan if it's not doable with GP.
How many parent categories will there be ?
If there are only a few then the simplest approach would be to:
1. create a Block Element - Page Hero for parent category 1.
2. add your GB block content for that category
3. set its Display Rules to Category Archive -> specific term
4. Repeat the steps for each category.
If there are a lot of Parent Categories then a more dynamic solution would make sense, but this would require some code to create the top section of content.
Let me know.
Thanks, David! I think this will work.
Glad to hear that!