-
Wolfgang
I’m trying to design archive-pages for different categories. I created an element (block – content template). To display a single category I set it to blog, post-category-archive, my-category.
In the element-option on the right I set it to content-template, tag-name:article, apply-to:post-with-term, taxonomy:category, term-name:my-category.
Problem #1: whenever I add anything to design the look of the page everything shows twice, no matter if I insert a dynamic content, a loop or a template element. I have tried everything that came to my mind, but nothing worked out. I didn’t find anything about this in the forum, so please help me with it.
Problem #2: I need to remove the category-title that is automatically displayed on the top, I want to replace it with a custom title and a paragraph.
It should look like this which I made without gp:
https://seifenwissen.org/thema/seifenfakten/Thanks for you help
Wolfgang -
Fernando
Hi Wolfgang,
For reference, can you provide admin login credentials so we can take a closer look at your setup?
-
Wolfgang
Hi Fernando,
I include it in the private information section. As you may see inbetween I did a workaround with single pages, unfortunately this does not help for the automatically generated category-pages that are linked e.g. from the breadcrumbs.
-
Fernando
I see. The way you’re using the Content Template is the issue.
This article has a video showing how to use it correctly: https://docs.generatepress.com/article/block-element-content-template/
Can you try how it’s done through the video first and see how it goes?
For the Title, you can use a Block Element – Page Hero: https://docs.generatepress.com/article/block-element-page-hero/
-
Wolfgang
Okay, thank you! I did the hook (see attached link) and I can style the top of the page. Now, please help me how to style the category-excerpts beneath. I would like to have a design with three columns for this page.
-
Fernando
Styling how Posts appear would be where the Block Element – Content Template would help.
As for the columns, would this be the only category page that would show post in three columns?
-
Wolfgang
There are different category-page-designs, three, two and one columns. I made the content template, link attached. What do I need to insert there – if I insert anything it again shows twice… (as there are two posts in the category)
-
Fernando
To change the number of columns for this category page, add this snippet:
add_filter( 'generate_blog_get_column_count','tu_search_column_count' ); function tu_search_column_count( $count ) { if ( is_category(24) ) { return 33; } return $count; }
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
-
Wolfgang
I added this to the functions.php, unfortunately it changes nothing.
What should I add in the content template?
-
Fernando
The video here shows what to add: https://docs.generatepress.com/article/block-element-content-template/
Can you set that up first and then, let’s address the columns afterward?
-
Wolfgang
Okay, seems to work now. If I apply the column-options are in customizer-layout-blog it looks fine. But I cannot use this option because I don’t want all the archive-pages to be in a three columns design.
-
Wolfgang
Okay, seems to work now. If I apply the column-options in customizer-layout-blog it looks fine. But I cannot use this option because I don’t want all the archive-pages to be in a three columns design.
-
Hi there,
it requires two filters:
add_filter( 'generate_blog_columns', function( $columns ) { if ( is_category(24) && ! is_singular() ) { return true; } return $columns; } ); add_filter( 'generate_blog_get_column_count','tu_search_column_count' ); function tu_search_column_count( $count ) { if ( is_category(24) ) { return 33; } return $count; }
Just update the
24
to the ID of the category you want to apply it to. -
Wolfgang
Hi David, thank you – unfortunately it doesn’t work. When I copy it to the functions.php and want to save it, I cannot, ’cause it says there’s an error in the second line line of your script “unexpected if”. Can you have a look please?
-
I am so sorry, i have updated the code above to fix that error.
-
Wolfgang
Perfect! Thanks a lot, David!
- You must be logged in to reply to this topic.