0

I need to retrieve only the first 5 images for a wordpress post but I don't know how to do this. I need to use this on a custom blog to be used on my home page. Any tips?

Thanks!

1

You have to get a post's attachments:

$attachments = get_posts( array(
        'post_type' => 'attachment',
        'posts_per_page' => 5,
        'post_parent' => $post_id,
    ) );
  • Glad to be of service! – Samyer Feb 28 '17 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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