In the members-only forum a user asked:
Hi, How can i display posts from 3 different categories on a page using ACF.
Like If i create a page called Themes, it will display three categories i.e Cat1 = “Themes News” at top and it will display 4 posts then Cat2= “Theme Reviews” at middle and it will display 4 posts as well and then Cat3 = “Theme guides” at the end and it will display 4 posts as well.
Also guide, I want to choose these three categories using ACF while creating this page. Because, I might need to create many pages like this. I would be very thankful, if you can write a tutorial about it.
In this tutorial we shall
- use ACF Pro to create a field group having a "Choose category and set number of posts" Repeater field and a "Titles Only?" True / False field and set it to appear below content on static Pages. The repeater field will have two sub fields, one for selecting the category and the other for setting the number of posts (with a default of 4).
- create a template for static Pages which checks if our repeater field has rows of data and if so, pass the category and number of posts as arguments to genesis_custom_loop()
- show only the linked titles for the posts if the "Titles Only" is ticked
When creating/editing any Page in the back end, any number of categories with corresponding number of posts can be set in any desired order.
Install and activate ACF Pro.
To view the full content, please sign up for the membership.
Already a member? Log in below or here.