Support

Account

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:
    Add Articles in Series

    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; ?>