3

I've tried displaying many post types (separated by comma) and it didn't work. Is there a way to achieve this?

$args = array( 'numberposts' => '5', 'post_type' => 'cpt1, cpt2, cptn');
    $recent_posts = wp_get_recent_posts( $args );

Thanks for your input.

1 Answer 1

5

Use post types as an array.

$args = array( 
    'numberposts' => '5', 
    'post_type'   => array('cpt1', 'cpt2', 'cptn') 
);
$recent_posts = wp_get_recent_posts( $args );
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.