按选择顺序显示帖子

Display posts in the order of their selection

我已经为我的客户提供了为每个 post 一一选择相关 post 的可能性。我已经使用 ACF 设置了一个自定义字段并使用它来显示选择的 posts 或随机的 posts :

<?php  $terms = get_the_terms( $post->ID , 'custom-taxonomy1' );  if ( !empty( $terms ) ) :?>
        <?php
        $related_acf = get_field('related_group');
        $rel_posts = $related_acf["related posts"];

        $related_ids = array();
        foreach ( $rel_posts as $rel_post) {
            array_push($related_ids, $rel_post['post']);
        }

        global $post;
        $current_post_type = get_post_type( $post );
    
        $terms = get_the_terms( $post->ID , 'custom-taxonomy1' ); 
        $term_ids = array_values( wp_list_pluck( $terms,'term_id' ) );
        $post_count_skrn = get_theme_mod('progression_studios_media_more_like_post_count', '3');
        
        if ( count($related_ids) > 0 ) {
            $args=array(
                'post_type' => array('custompost1', 'custompost2', 'post'),
                'post__in' => $related_ids
            );
        } else {
            $args=array(
                'post_type' => $current_post_type,
                'posts_per_page'=> $post_count_skrn, 
                'orderby'=>'rand', // Randomize the posts
                'post__not_in' => array( $post->ID ),
                'tax_query' => array(
                    array(
                        'taxonomy'  => 'video-genres',
                        'terms'     => $term_ids,
                        'field' => 'id',
                        'operator'  => 'IN'
                    )
                ),  
            );
        }   

所以我想知道我是否可以添加类似的内容:

if ( count($related_ids) > 0 ) {
            $args=array(
                'post_type' => array('custompost1', 'custompost2', 'post'),
                'orderby'=>'XXXXX', // Ordering the posts with the order of selection
                'post__in' => $related_ids
            );   

此致, 克莱门特

WordPress 有 'orderby'=>'post__in'

现在将根据帖子在 $related_ids 数组中的位置显示帖子

 $args=array(
 'post_type' => array('custompost1', 'custompost2', 'post'),
 'orderby'=>'post__in', // Ordering the posts with the order of selection
 'post__in' => $related_ids
  );