$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
- Add screen options to custom admin pages
- Completely remove WP_Admin_Bar for specific user roles
- WordPress and PHP Sessions – Security and Performance
- WordPress Hook for user register
- How to make repeated component/block in Gutenberg
- Must-use plugins autoloader: How to use get_plugins() correctly?
- Changing upload directory for plugin uploads only
- Upload file to remote storage
- wp_localize_script $handle
- Why won’t register_setting() create a setting?
- One time username change from frontend?
- Customizer Not Saving Options
- How to extend a plugin like we do a theme?
- How to add custom text in wordpress logs
- Rewrite url for existing page without flush_rewrite_rules
- Front-End Interfaces Without Shortcodes
- Is there a way to loop through a shortcode datasource to create a table?
- Execute plugin for specific user role(s) only
- WordPress REST API, run long background job
- Make a list with header and subtext in Gutenberg blocks
- Get the post id as early as possible
- Custom plugin changes not showing
- How plugins_loaded works?
- the_editor() function
- How To Prevent Certain Folder To Be Overwritten During Plugin Update?
- Force HTTPS 301 redirect with hook
- wordpress JSONAPI introspector always limits number at 10?
- TinyMCE editor turns white on Biographical info [closed]
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- How I can use order by of the custom post title?
- Custom Post Type to override theme’s CSS & HTML from Plugins Dir?
- Move some files of plugin to the root directory with plugin activation
- enabling Twig as Template Engine withing own plugin [closed]
- Unable to get a simple plugin admin page to work
- Use npm and wp-env to make production bundle
- Set _regular_price 0 if empty in woocommerce product
- How do I get rid of my inclusion race-condition on wp_enqueue_script
- Form using admin-post.php gives 404 after submission
- per blog metadata for plugin
- AJAX call to admin-ajax.php by subscriber returns home page
- How to use gettext for specific user role
- Ajax function is not working on WordPress
- Best way to ping for the API changes in the wordpress?
- Should I put my plugin javascript inline?
- Get Posts by IDs (optionally)
- Can / should a widget plugin define its own Widget Area?
- How do I duplicate a single post, with all its properties, and save it as a different post?
- Why doesn’t my Table get created?
- want to show CMB2 metabox on woocommerce product data tab
- How to get the `comment_post_ID`?
- Can someone explain what’s the use of parse request function in WordPress?
- Add parameters to 3rd party callback function
- How does update method in Widget class saves $instance array from Select tag?
- WooCommerce – Stop assigning order numbers
- How can I pass WP_Query results to a plugin?
- WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
- WC_Geolocation not found inside plugin
- Set widget icon in Customizer?
- How to customize the size of Featured Images or Post Thumbnails in WordPress?
- Why does unzip_file always return true but nothing happens?
- Let user override plugin CSS
- What happens when you create/edit a menu
- Add_menu_page and saving settings
- Updating Style From WP Options Setting Page
- What method would I use to show an image in between X amount of posts on category archive? [duplicate]
- Plugin – Proper way to handle 404 pages?