- This topic has 6 replies, 3 voices, and was last updated 3 years, 3 months ago by
Fernando.
-
AuthorPosts
-
December 27, 2022 at 6:57 am #2474676
Michael
Hello – can you please provide a link to a tutorial on creating customized dynamic archive pages? I just want to create a grid at the top of the each archive page with some styling and then a container below that lists posts in a 2 or 3 column format. I’ve been playing with elements, query loops, etc. and just can’t figure it out. (I have GP Premium).
Something like:
Container
Container/Grid — Category Name
Container/Grid — Category Desc
Container
Repeat
Container/Grid — Post title, post excerpt
Container/Grid — Post title, post excerpt
Container/Grid — Post title, post excerptDecember 27, 2022 at 7:19 am #2474693Michael
My indentations were clipped out:
Container
##### Container/Grid — Category Name
##### Container/Grid — Category Desc
Container
##### Repeat
##### Container/Grid — Post title, post excerpt
##### Container/Grid — Post title, post excerpt
##### Container/Grid — Post title, post excerptDecember 27, 2022 at 1:19 pm #2475066Ying
StaffCustomer SupportHi Michael,
You can use a
block element - loop templateto build custom archive pages, it will be like building a static page.For more info:
https://docs.generatepress.com/article/block-element-loop-template/December 27, 2022 at 2:48 pm #2475119Michael
Thanks Ying – this got me 95% of the way there. The remaining challenge I have is displaying the description for the category. I use dynamic text to display the category name by choosing title, but I can’t get the category description to display – I have tried using term meta and post meta as well as entering “Description” as the meta field name.
In summary, for my example category of “Holiday Posts” I am able to dynamically render the category title and loop/list all the posts that are assigned to the category, but I am unable to get the description for the category to dynamically display.
Thanks again for your help.
December 27, 2022 at 7:08 pm #2475235Fernando Customer Support
Hi Michael,
To do this, add a static GB Headline Block. Give it a text –
placeholderGive it a class of
get-term-descriptionAdding Custom Classes: https://wordpress.com/support/wordpress-editor/adding-additional-css-classes-to-blocks/
Then, add this PHP snippet:
add_filter( 'render_block', function( $block_content, $block ) { if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'get-term-description' ) !== false ) { $myreplace1 = 'placeholder'; $myinsert1 = get_the_archive_description(); $block_content = str_replace( $myreplace1, $myinsert1 , $block_content ); } return $block_content; }, 10, 2 );Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
December 28, 2022 at 6:20 am #2475648Michael
Thank you Fernando.
December 28, 2022 at 5:45 pm #2476302Fernando Customer Support
You’re welcome, Michael!
-
AuthorPosts
- You must be logged in to reply to this topic.