I have a page template that has a dropdown custom field.
I’d like to display all published pages that share the same value in the dropdown field.
Page 1 – published – dropdown-field-value: “AAA”
Page 2 – published – dropdown-field-value: “BBB”
Page 3 – published – dropdown-field-value: “CCC”
Page 4 – draft – dropdown-field-value: “AAA”
Page 5 – published – dropdown-field-value: “AAA”
The query should display the pages 1 & 5
Can anyone push me in the right direction?
Thanks a lot!
thank you, this brought me a big step forward.
I got all pages displayed that share a dropdown-field-value.
Unfortunately now I’m struggling with the ordering.
To be more concrete:
– I got 6 pages that are part of a series
– In the ACF-Template of these pages I have:
— a dropdown for the series they belong to (dropdown field)
— a dropdown for the prev page in the series (page field)
— a dropdown for the next page in the series (page field)
As stated above I got all pages displayed that share a series.
But for the ordering: How can I display in the correct order?
My current code looks like this:
$posts = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'page',
'meta_value' => 'series1',
if( $posts ): ?>
<ul class="list list--styled">
<?php foreach( $posts as $post ):
setup_postdata( $post );
<a href="<?php the_permalink(); ?>">
<div><?php the_field('title_short'); ?></div>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>