Home › Forums › General Issues › Display all pages that share a custom field value › Reply To: Display all pages that share a custom field value
Hi HQ80,
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)
Image:
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:
<?php
$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 );
?>
<li>
<a href="<?php the_permalink(); ?>">
<div><?php the_field('title_short'); ?></div>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.