WP_Query Group By Help!
-
Hi, I have a bunch of pages published on my local wordpress setup.
Lets say for a simple example, each page contains the standard the_title(), the_content() and 1 custom field:- get_field(‘section’) (Im using the advanced custom field plugin).
I want to create a kinda of index page, which lists all the published pages and groups them based on the custom field value of ‘section’.
So, I have say 4 pages assigned to a section called ‘Oranges’
3 pages with section called ‘Apples’
10 pages with section called ‘Pears’Im trying to setup a shortcode within function.php and using WP_Query to loop through through all the ‘Oranges’ pages, and list them together, then loop through all the ‘Apples’ pages, and so on and so forth.
How can I achieve this with just one shortcode ? Currently Im no using categories if that helps at all.
Any info much appreciated.
- The topic ‘WP_Query Group By Help!’ is closed to new replies.