- This topic has 20 replies, 4 voices, and was last updated 3 years, 1 month ago by
Adar.
-
AuthorPosts
-
February 26, 2021 at 3:33 am #1673497
Ales
Hi,
I would need to create a custom category page. Is that possible with Generate Blocks Pro?
I need to create an article as a category with no latest posts showed and a category with some custom blocks at the top, and then below with the latest posts.
Is it possible to do this with Generate Blocks Pro?
Thanks!
AlexFebruary 26, 2021 at 5:27 am #1673574David
StaffCustomer SupportHi there,
You can use a Block Element to hook in any content you want above the list of posts on standard category archive page:
https://docs.generatepress.com/article/block-element-overview/
In GPP 2.0 Alpha that content can include dynamic data:
March 1, 2021 at 2:37 pm #1677986Ales
Hi David,
Thanks for your reply. This helps, but it’s still not exactly what I want to achieve.
The problem is following:
1) I have this basic category:
https://dogfate.com/rescues/
This category should look like this:
https://www.animalfate.com/dog-breeders/
This is possible with the approach you mentioned before.2) I have this sub-category:
https://dogfate.com/rescues/golden-retriever/
This category should look like this:
https://www.animalfate.com/shih-tzu-breeders/
Basically, it’s an article that links to other sub-pages, but I need to have this as a category, so the breadcrumbs are working properly:

For this sub-category, I don’t want to show the latest posts.3) I have the final article:
https://dogfate.com/7-golden-retriever-rescues-in-michigan/
There is no need to change anything.Is this possible? The problem is the sub-category where I need to stop showing the latest posts.
Elementor can do that, but I don’t want to use Elementor because it slows down the website. And I don’t want to use any redirects because that would mess the breadcrumbs.
Thanks a lot!
March 2, 2021 at 1:46 am #1678395David
StaffCustomer SupportHow does Elementor all you to replace a Sub Category with a single post / static page?
It may give me some other ideas.March 2, 2021 at 7:55 am #1679011Ales
Hi David,
You go to Elementor templates in WP-Admin and add a new template as an archive:

Then you design the page as you want with all the Elementor options available. You can select if you want to show the latest posts, archive title, but you can also fully customize it.
When you hit publish, you have to select where you want to display this template, so you select “Categories,” and there, you can select any category or sub-category you wish.

And the result is this: https://dogfate.com/rescues/golden-retriever/
A fully custom page with no posts showed that is still a category (sub-category in this case).
You can also check this final article: https://dogfate.com/11-golden-retriever-rescues-in-georgia/, where you can see in breadcrumbs that it works like a normal category.
March 2, 2021 at 9:47 am #1679135David
StaffCustomer SupportSo i assume you’re having to create a separate Elementor template for each of those ‘categories’ right ? As the category archive itself cannot be edited.
In GP you would need to disable the Loop on the Category pages using this PHP Snippet:
// Disable loop on category archives add_filter( 'generate_do_template_part', function( $do ) { if ( is_category() ) { return false; } return $do; } );Then you can use a Block Element and use a generate_before_main_content hook set to the display on the specific Category Archive.
March 2, 2021 at 12:13 pm #1679353Ales
Hi David,
That’s correct. You need to create a template for each category page.
Thanks for the PHP snippet. Is there any way how to use it only for some categories, for example by ID? I still want to show posts in some categories.
Thanks!
AlexMarch 2, 2021 at 11:08 pm #1679763Elvin
StaffCustomer SupportHi Ales,
You can actually specify the category/categories within the
if( is_category())condition on the PHP snippet David provided.See codex reference here:
https://developer.wordpress.org/reference/functions/is_category/#comment-498You can see different usage on the linked comment.
March 14, 2021 at 8:52 am #1694830Ales
Hi,
I finally had time to test this and I have 3 problems:
1) When I use that PHP snippet that disables the loop on category archives, it also removes the Block Element where I have the content. This happens when I use generate_before_content as a hook, which I have to because when I use generate_before_main_content, it’s generated above the H1 (category name) and it’s not within the container with white background. Here is an example: https://dogfate.com/rescues/golden-retriever/
I need to have my content generated under this H1 and inside the white container.
2) Is there any way how I can change the H1 that shows on the category page so it’s different from what is the category name? Maybe here solution can be to just remove the original H1 and I will use my own in that Block Element. But still needs to solve the white container issue.
3) When I look into the code, there are blank spaces inside the H1 tag, why is that, please?

Thanks a lot!
AlexMarch 14, 2021 at 3:36 pm #1695131Elvin
StaffCustomer Support1.) Ah yes that was actually the purpose of the code. The category specified within the condition means it won’t run the loop on that particular archive so it won’t interfere with your category archive page made from elementor.
Unless we’ve misunderstood and that’s not what you’re trying to do? Let us know.
2.) If you’re making the template from Elementor. All the things you’ll see will be whatever you set for the template.
3.) Can you check the category label for any spaces? This particular element fetches whatever was placed within the Category Label field.
March 14, 2021 at 6:39 pm #1695212Ales
Hi Elvin,
Thanks for your reply.
Just for clarification, I decided to uninstall Elementor completely and use only GeneratePress and GenerateBlocks for this. Elementor is nice and does exactly what I need, but it’s also very slow.
1) For example, this page: https://dogfate.com/rescues/golden-retriever/. I want to have the content in a white container under the H1, which is currently “Golden Retriever”. Right now, the content is above the H1, and it’s just on the grey background, not in a white container.
2) I don’t use Elementor anymore. The thing is that when I use the H1 tag inside Block Element, there will be 2x H1 tags on that category page. One default, one from Block Element.
3) There are no spaces. And it seems like this issue is also for other categories and on my other site.
Thanks,
AlexMarch 15, 2021 at 7:25 am #1696093David
StaffCustomer SupportIn your Block Element try using the Hook:
before_do_template_part
Let us know if that works for you – and then we can look at the other things.March 15, 2021 at 8:36 am #1696184Ales
Hi David,
Thanks a lot. It helped, but there are still 2 things. It looks like this: https://dogfate.com/rescues/golden-retriever/
Problems:
1) It’s not in the white container like all content is.
2) The text is displayed multiple times, probably once for each post that should be in that category.Thanks!
AlesMarch 15, 2021 at 9:35 am #1696246David
StaffCustomer SupportIn that case – change the Hook to Custom Hook and in the field provided add:
generate_after_loop
You will have to add a Container Block as paren wrapper for your content to which you can add a background color and padding.March 15, 2021 at 2:22 pm #1696515Ales
Hi David,
Thanks a lot, this works!
So, now the only thing I need to fix is that H1. Can I somehow have a different H1 than the category name? I can create an H1 heading in the category content, but the problem is that there is still the old one.
I tried this CSS:
.category .page-header { display: none; }And it looks exactly as I want (https://dogfate.com/rescues/golden-retriever/), but the original H1 (Golden Retriever) is only hidden, not removed, and I can’t have two H1 on the same page.

Thanks!
Ales -
AuthorPosts
- You must be logged in to reply to this topic.