Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I'm not mistaken (which I most certainly may be), you can't do a query like you're trying to do with Wordpress's built in functions.</p> <p>What you can do is in your functions.php file (where one stores the theme's custom functions) having a function which takes an array of argument arrays and loops through them with every pass adding the returned posts to an array. I think <a href="http://codex.wordpress.org/Function_Reference/get_posts" rel="nofollow" title="get_posts()">get_posts()</a> would be the best function to use for this since it returns the posts in an array instead of needing the Loop.</p> <pre><code>function query_posts_multiple($arrArgs) { if (!is_array($arrArgs)) return false; // Prevents warnings and fatal errors. $posts = array(); foreach ($arrArgs as $args) { $posts = array_merge($posts, get_posts($args)); } return $posts; } </code></pre> <p>For the args array, here's an example:</p> <pre><code>$args = array(); $args[] = array( 'numberposts' =&gt; 7, 'tag' =&gt; "50", ); </code></pre> <p>You would just use a foreach() loop in your theme. You would access the data using a $post-><em>column</em> fashion.</p> <pre><code>$posts = get_posts_multiple($args); foreach ($posts as $post) { // call all the $post-&gt;COLUMNs your heart desires } unset($posts); // Delete that variable just to be safe. </code></pre> <p>To limit the number of posts, just keep count and stop the loop when you reach a certain number. To randomize your array, you can use <a href="http://php.net/manual/en/function.shuffle.php" rel="nofollow">shuffle()</a>. </p> <p>This is probably a very, very dirty way of doing this, blame it on my extreme tiredness...</p> <p>Logan</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload