$all_the_images = get_attached_media( 'image', 31 );
should return any image attachments for a page the ID of 31 if that page has child images. Meaning, there are images that were uploaded and actually attached to that page, not just upload and inserted into that page.
When you use the media uploader (to upload images), from within the Edit screen of the page you’re editing, WP automatically makes those images children of that page. That’s what get_attched_media()
returns. If you just use the media uploader to browse the media library and insert images into the content body of the page you’re editing get_attched_media()
won’t pull those.
Related Posts:
- Hook in wp.media to add a new tab
- Overide get_template_part( ‘partials/post’, ‘sidebar’ ); with a plugin
- What’s the earliest point I can get the queried object ID?
- Using Primary Color in Plugin Block
- Using a Theme inside a Plugin directory
- Plugin development without Theme adjustments?
- What is the best way to provide plugin users with a way to customized the styles
- Programmatically Selecting Theme Based on URL
- How to properly use a hook to create template for custom product type in a plugin such as Woocommerce? [closed]
- Fully automated theme install and activation via a plugin
- Calling plugins API within a theme
- Hook into theme-switching later than `setup_theme`
- WordPress security issue to output data from user input from theme option form
- Which themes do you use to test compatibilities with your plugin [closed]
- How to Debug: My Plugin Interferes With My Theme
- Theme Install using a Custom Repository
- Auto-Populate Image After Media Upload
- How to create a backend for a custom theme?
- How to make “upgrade safe” theme for a plugin?
- Are there any official or unofficial guidelines for the styling of a widget?
- Create fixed static pages
- How To Protect Plugin Display From Being Affected By Theme’s CSS
- Displaying custom content from a plugin within the active theme
- Getting Post ID at “stylesheet” and “template” hooks
- WordPress admin panel not working
- Override category archive page title (not the head title)
- How to hide/remvoe unnecessary field/section in post edit section ( Dashboard )
- Redirect theme directory to plugin theme directory
- Adding and handling custom settings tab to fusion element
- Post Pagination does not working on WP-Query
- Managing Custom Designed Content
- Create and style menu
- Developing Themes on WordPress, Looking for Excellent Tutorials [closed]
- Find Any Theme’s page.php File
- Theme / Divi change visitor css and site logo and all site urls based on REQUEST_URI non logged in wp user
- How to give a NavWalker its own stylesheet?
- Objective Best Practices for Plugin Development? [closed]
- add_menu_page() with different name for first submenu item
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- How to include PHP files in plugins the correct way
- How can I add an image upload field directly to a custom write panel?
- A tool to analyze rewrite rules? [closed]
- Difference Between Filter and Action Hooks?
- framework for plugin/theme options panel? [closed]
- Creating a table in the admin-style?
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- Settings API with arrays example
- How to get the path to the current theme?
- How to make a plugin require another plugin?
- ajaxurl not defined on front end
- What process do you use for WordPress development? [closed]
- What’s the difference between term_id and term_taxonomy_id
- Should I use wpdb prepare?
- Why does WordPress use outdated jQuery v1.12.4?
- Post meta vs separate database tables
- Is there any plugin development framework
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How to add a javascript snippet to the footer that requires jQuery
- Enhance Media Manager for Gallery
- How do I create a custom role capability?
- How do I add CSS options to my plugin without using inline styles?
- How do i best handle custom plugin page actions?
- Adding Custom Text Patterns in the WP 4.5 Visual Editor
- Automatically determine minimum WordPress version required for a plugin?
- What is the advantage of using wp_mail?
- How to make a WordPress plugin translation ready?
- How many times will this code run? (or, how rich is grandma?)
- How to create an API for my plugin?
- Is it ever okay to include inline CSS in plugins?
- Plugins in symlinked directories?
- How to override existing plugin action with new action
- How to include a file using get_template_part() in a plugin?
- Add custom TinyMCE 4 Button, Usable since WordPress 3.9-beta1
- How to store username and password to API in wordpress option DB?
- body_class hook for admin pages
- “Error: Options Page Not Found” on Settings Page Submission for an OOP Plugin
- Is it mandatory to use $wpdb->prefix in custom tables
- Which hook should be used to add an action containing a redirect?
- add_action hook for completely new post?
- Why does WordPress add 0 (zero) to an Ajax response?
- What should I use instead of WP_CONTENT_DIR and WP_PLUGIN_DIR?
- How to enqueue JavaScripts in a plugin
- In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
- Plugin Form Submission Best Practice
- How to redirect to settings page once the plugin is activated?
- Is get_option function cached?
- Should Plugin Folders Include a Blank index.php File?
- Unit testing for plugin development
- Methods of Integrating Plugin Data with Themes
- What is the wordpress wp-includes folder for?
- WordPress Update Plugin Hook/Action? Since 3.9
- How to include jQuery and JavaScript files correctly?
- How come `wp_options` table does not have an index on `autoload`?
- PHP error with shortcode handler from a class
- Update Option Stored in Multi-Dimensional Array
- check if Gutenberg is currently in use
- Best way to abort plugin in case of insufficient PHP version?
- WordPress Plugin Development – Headers Already Sent Message
- WP 3.3 How to Add Menu Items to the Admin Bar?
- dbDelta not creating tables