0

Based on this previous WPSE question:

I tried a limit of 10 files, but it did not work:

if ( count( get_posts( "post_type=attachment&post_parent={$post_id}" ) ) > 10 )

How to limit it to 10 images?

Thanks

1

here you go:

get_posts(array('post_type'=>'attachment', 'numberposts' => 10, 'post_parent' => $post_id));

this will return you upto 10 posts.

  • if you want to get only published files, you should use 'post_status' => 'published' too. – HungryCoder Jun 18 '12 at 14:10
  • I want to limit to only upload 10 images per post... – Antonio Jun 18 '12 at 19:47

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.