there will be lot of users on my site who will be author uploading their posts. right now, they can upload as many images / videos per post as they want. i want to restrict them to upload maximum 4 images / videos per post. can anybody help me please ?
Leave a Reply
You must be logged in to post a comment.
try this:
after you paste this in your theme’s functions.php the upload limit should be 4 files total per post.
I have also on solution, use same idea and hooks, only more complex with more functionalities and structured in classes for easy reused. Was an customer project and now its free: https://github.com/bueltge/Limit-Upload
Anyone wishing to use this code, be sure to include the
'posts_per_page' => -1
if you want to limit the number to more than 5 because theget_posts
query on this page will only get a max of 5 because of the default paging.see https://stackoverflow.com/questions/2134500/why-does-get-posts-return-only-5-matching-posts-when-it-should-return-9 for more information. Cheers!