cgee cgee - 5 months ago 30
PHP Question

Get three specific wordpress posts and random the output

I've this wordpress


$arg = array(
'orderby' => 'rand',
'numberposts' => 1,
'post_type' => 'dmd_berater',
'post_name' => 'test1',
'meta_query' => array(
'key' => 'dmd_subject',
'value' => 'Daten und Analysen',
'compare' => 'LIKE'
$consultant_post = get_posts($arg); //contains ALL posts.

The code above contains all posts but I only want the post with the

Is this possible? And how?

It should be great if I can output three specific posts. I think it should be work with an array? Like:

'post_name' => array('test1', 'test2', 'test3'),

First question:

Can somebody find my issue?

Second question:

Is an array possible?


'post_name__in' => array('test1', 'test2', 'test3')

See the paramters section for more informations.