There is no such a solution out of the box, and any files uploaded to WP are publically available to anyone who can access the domain, so you might want to keep that in mind.
You’ll need to code a solution, possibly as follows:
- on post creation, use
wp_insert_post
to create the require folder. - Use something like
glob($root_folder.$post_slug . "/*.{jpg,jpeg,png,pdf}",GLOB_BRACE)
to list all files in the post-specific folder . (Note, if the slug is ever changed, you’ll need to manually rename the folder or automate it somehow. - Use
before_delete_post
to delete the folder & all files.
Related Posts:
- Pulling images from the media folder category to display inside a page
- How to Protect Uploads, if User is not Logged In?
- Add infinite scroll to content splitted post
- Check if wp-login is current page
- How to get current page ID outside the loop?
- Add a menu item to WordPress 3.5 Media Manager
- How to Fix HTTP Error When Uploading Images?
- Contact Form on WordPress Sites?
- Enhance Media Manager for Gallery
- Page returns 404 with POST variables, but not without
- Custom templates not showing up in template dropdown
- Get page id by template
- Using pre_get_posts on true pages and static front pages
- Get the content of a specific page (by ID)
- Extend Media Library
- How to get page title with the page ID?
- Show more than 20 items in pages or posts edit dashboard
- Allowing user to edit only certain pages
- WordPress 3.5: Setting custom “full URL path to files” in the Media Library?
- Delete an attachment in the WP media modal window
- How to display last 3 posts (recent posts) in a static page?
- How to give paged links custom title?
- How to set post slug when using wp_insert_post();?
- How can I keep the content of my pages version controlled?
- How to load javascript on custom page template?
- Upload images to remote server
- How to configure WordPress to handle 75,000 pages?
- How to update page status from publish to draft and draft to publish
- Check if is on child-page of a particular page
- Change page template programmatically ?
- Conditional tag to check if ‘page.php’ is being used?
- Customizing the URLs of WordPress Login and Sign-up Pages?
- How to disable posts and use pages only
- featured image as background image on pages
- Check IF is a “single product page” and Check the “role” for a Redirect
- How to show all available images in WP’s media library when using the Polylang plugin?
- A check for if is parent page, if has children, if has grandchildren
- Delete Associated Media Upon Page Deletion
- How to load JS and CSS only on specific Pages using is_page()?
- Listing pages which uses specific template [duplicate]
- Media library to list images only user uploaded
- WordPress 3.5 Media Manager – add a button
- Proper way to get page content
- Access the same page from multiple urls (wildcard)
- Create a page without adding a page in the Database
- Is there a way to change the default page template selection?
- Can I have two child pages of different parents with the same name?
- What methods to use to create small, editable pieces of text for static pages?
- Rendering the uploaded file in a wp.media object
- Show Default Editor on Blog Page ( Administration Panel )
- How can I bulk delete media and attachments using WP-CLI?
- Hide page visual editor if certain template is selected?
- What is the difference between $paged and $page?
- Remove “Insert from URL” link in Media upload – WP 3.5
- Which filters or actions to use after a media upload and delete?
- How do I force WordPress to show most recent version of images in the media library?
- WordPress Media Manager 3.5 – default link to
- multi page password protection
- Create a “Dummy” parent page for a hierarchy in page listing?
- Proper way to add a button to the top menu of the media library?
- How do I convert a page’s title to lower case?
- Get top level page parent title
- How to add a specific widget to only 1 page?
- Restrict admin access to certain pages for certain users
- page title, parent tilte and grand parent title
- Protecting direct access to PDF and ZIP unless user logged in (without plugin)
- How to add jQuery script to an individual page?
- How to wp_upload_bits() to a sub-folder?
- Filter by post category in Media Library
- Change Media Uploader default directory
- display image size in media library screen
- WordPress page edit does not save selected template
- Add a Page without header and menus?
- How to hide media uploads by other users in the Media menu?
- What is an alternative to get_page_by_title()?
- Password protect page with multiple passwords
- Create pages automatically if they don’t exist
- Find empty pages or pages which have less than x characters
- “Add Media” only shows “Full Size” under Attachment Display Settings
- Where do the favicons for Media Files come from
- Update media file url in wordpress media library
- Allow only new sub-pages to be created
- Set page template automatically based on parent
- Editing Complex Pages in Visual Mode
- How to capture the selection:toggle event fired by wp.media
- Link section within page with slash (/) and not hash (#) without reloading the page
- Creating a template using a specific slug name, for a page with a parent page
- Can I display submenus in groups, using wp_list_pages?
- Is there a default template file for child pages / subpages?
- Get wp_get_attachment_url outside of loop
- Is there a user-facing interface to edit an attachment’s permalink?
- Is it possible to trigger some JavaScript when Media Popup is opened?
- Order by menu_order and title?
- How to call WP3.5 Media Library manager?
- Require title for pages
- WP Page and Subdirectory with same name
- Replace Dashes Before Title in Page List
- Add a new page to wordpress programmatically
- Creating a metabox to upload multiple images, Ignoring The Featured Image
- Hide old attachments from wp media library