• I have an array $foo with a list of page IDs and I’d like to modify $query to display this array (including duplicates); so far I’m using posts__in but this automatically excludes duplicates, here’s what I’ve tried:

    add_action('pre_get_posts','alter_query');
    
    function alter_query($query){
     $foo = array('one'   => get_theme_mod("featured__one", "default_value" ),
                  'two'   => get_theme_mod("featured__two", "default_value" ),
                  'three' => get_theme_mod("featured__three", "default_value" ),
                  'four'  => get_theme_mod("featured__four", "default_value" ),
    );
    
            if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'post_type',  'page'  );
            $query->set ('post__in', $foo ) ;
    
        }
    }

    The problem so far is I can’t find a property that accepts my array of page ids and (possibly) outputs this array keeping the input order.

  • The topic ‘wp_query – $query to include duplicate content’ is closed to new replies.