Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

here you go:

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

this will return you upto 10 posts.

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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