WP_Query Order Posts By Custom Meta Value Array Not in Codex
<p>I have a different sort of post order I'm trying to return that I can't find anywhere with an answer.  I'm using a wp_query to try to order posts by a list of meta values.  However non of the standard orderby options do what I'm trying to achieve.</p>

<p>My meta values are stored as a comma list string like so:</p>

<p>1, 5, 10, 3, 21, 6</p>

<p>Then I grab those values and explode them to an array like so:</p>

<pre><code>$banner_nums = get_option('banner_numbers');
$nums_array = explode( ',', $banner_nums );
</code></pre>

<p>I do a standard wp_query, but the catch is, I'm trying to order the display of these posts by the actual order in my $banner_nums variable, not by any normal wp_query orderby such as 'ID', 'date', 'title', 'meta_value', etc. </p>

<p>Display like so:</p>

<p>1st: post with meta_value = 1</p>

<p>2nd: post with meta_value = 5</p>

<p>3rd: post with meta_value = 10</p>

<p>4th: post with meta_value = 3</p>

<p>5th: post with meta_value = 21</p>

<p>6th: post with meta_value = 6</p>

<p>If, for example, I want to display the post with meta_value = 6 as the 2nd post I'd change my list to: 1, 6, 5, 10, 3, 21.</p>

<p>Here is my query that grabs my posts fine, I just can't get them to order correctly.</p>

<pre><code>$slider_args = array(
    'post_type' =&gt; 'property',
    'posts_per_page' =&gt; -1,
    'nopaging' =&gt; true
);

$my_query = array();

foreach( $nums_array as $k =&gt; $v ) {
    $my_query[$k]['key'] = 'property_id';
    $my_query[$k]['value'] = $v;
    $my_query[$k]['compare'] = '=';
}

$slider_args['meta_query'] = $my_query;
$slider_args['meta_query']['relation'] = 'OR';

$slider_query = new WP_Query( $slider_args );

if ( $slider_query-&gt;have_posts() ) {
    stuff...
}
</code></pre>

<p>Printing my $slider_args looks like this, which looks fine:</p>

<pre><code>[post_type] =&gt; property
[posts_per_page] =&gt; -1
[nopaging] =&gt; 1
[meta_query] =&gt; Array
    (
        [0] =&gt; Array
            (
                [key] =&gt; property_id
                [value] =&gt; 1
                [compare] =&gt; =
            )

        [1] =&gt; Array
            (
                [key] =&gt; property_id
                [value] =&gt;  5
                [compare] =&gt; =
            )

        [2] =&gt; Array
            (
                [key] =&gt; property_id
                [value] =&gt;  10
                [compare] =&gt; =
            )

        [3] =&gt; Array
            (
                [key] =&gt; property_id
                [value] =&gt;  3
                [compare] =&gt; =
            )

        [4] =&gt; Array
            (
                [key] =&gt; property_id
                [value] =&gt;  21
                [compare] =&gt; =
            )

        [5] =&gt; Array
            (
                [key] =&gt; property_id
                [value] =&gt;  6
                [compare] =&gt; =
            )

        [relation] =&gt; OR
    )
</code></pre>

<p>I just can't figure out how to display the posts in the correct order of</p>

<p>1, 5, 10, 3, 21, 6</p>

<p>I hope I'm making sense?  Any help is much appreciated.</p>