- This topic has 7 replies, 3 voices, and was last updated 3 years, 3 months ago by
David.
-
AuthorPosts
-
February 25, 2023 at 11:02 am #2546825
Paul
Hi There,
Could you help me with the following.
I’d like to add a I’d 3 ‘featured’ posts before the archive of all posts in category archive page. Could you give me any pointers on how I could do that (example page in private info)?
cheers
February 26, 2023 at 6:27 am #2547351David
StaffCustomer SupportHi there,
the featured posts .. are they specific to each category ?
February 26, 2023 at 6:52 am #2547389Paul
Hi David,
Yes they would featured posts from the same category so ideally would like to filter those out posts from the full listings for the archive below, if that makes sense.
So would be:
CATS CATEGORY Cats Featured Post 1 | Cats Featured Post 2 | Cats Featured Post 3 ____________________________________________________________________________________ List of other Posts in Category (filtered to not display 3 featured posts above)February 26, 2023 at 5:28 pm #2547926Ying
StaffCustomer SupportHi Paul,
Yes, you can use a block element – loop template, and assign it to the category archive.
You will be adding 2 GB query loop blocks.
The 1st query loop block is to have 3 featured posts, you can manually select the 3 posts.
The 2nd query loop block is to have the rest posts, you can exclude the 3 posts.February 27, 2023 at 4:11 am #2548400Paul
Great, thank you Ying – I’ll try that.
February 27, 2023 at 11:16 am #2549062Ying
StaffCustomer SupportNo problem 🙂
February 27, 2023 at 3:43 pm #2549301Paul
Hi Ying,
I gave that a try (I only added the first query loop block so far) – See link in private info.
Although I ran into an issue – what if we want the ‘Featured posts’ query loop block container to only show on the first page of the category archive (currently shows on all pages)?
Cheers
February 28, 2023 at 5:12 am #2549813David
StaffCustomer SupportAdd this snippet to your site:
function db_hide_block_on_paged( $block_content, $block ) { if ( is_paged() && ! empty( $block['attrs']['className'] ) && 'hide-on-paged' === $block['attrs']['className'] ) { $block_content = ''; } return $block_content; } add_filter( 'render_block', 'db_hide_block_on_paged', 10, 2 );Then any Block you want to remove on paged instances eg. the parent Container holding your featured post loop, give it an Advanced > Additional CSS Class of:
hide-on-paged -
AuthorPosts
- You must be logged in to reply to this topic.