Displaying Dynamic Categories and Posts from ACF in Bricks

Hello Bricks community,

I’m building a blog home page that displays selected categories and recent posts. The site uses native WordPress categories and posts.

I aim to have the page show specific categories chosen by the editor, along with the 10 most recent posts for each category.

For example, the editor of the site may select the “Space” and “Jungle” categories to display. The page would show:

  • Space

    • Post title 1
    • Post title 2
    • (8 more post titles)
  • Jungle

    • Post title 1
    • Post title 2
    • (8 more post titles)

The editor needs to be able to control which categories are displayed from an ACF field on a specified WordPress page, not directly in Bricks.

When new categories are added, they could also be selected to display on the home page with the associated posts. Unselecting a category would remove it and its posts from the listing.

I understand how to get the posts and display the titles, metadata, featured images etc., both with and without ACF. I can also display a list of selected categories using ACF.

However, I’m not sure of the best way to iterate through the selected categories and display the posts for each one.

If anyone has advice on how to loop through the categories and pull in the posts, I would greatly appreciate it! I’m still learning how to combine these elements in Bricks and ACF.

Please let me know if any part of the explanation needs clarification. Thanks in advance for your help!

1 Like

My gut tells me you will have to follow something similar to Kevin’s approach in this video

With a toggle and data attributes you might be able to make it work.

1 Like

Hi @kshitij,

Thank you so much for this video. I watched it and tried, but no luck. Maybe I will need to try again, or this won’t be the solution to my use case.