I believe this will get you all of your attachments:
$q = new WP_Query(
array(
'post_type'=>'attachment',
'post_status'=>'inherit'
)
);
var_dump($q);
You could further restrict that by adding other parameters, for example, 'post_mime_type' => 'image'
would restrict only to images.
That will return all images though, not just the ones attached to posts. What you want is post_parent != 0
but I don’t see a way to do that with WP_Query
. If you var_dump
that query though you can steal its SQL and add the parameter, or build a posts_where
filter.
Related Posts:
- Redirect to another page using contact form 7? [closed]
- Copy/paste local images not working in WordPress
- WordPress ultra slow if I click on posts?
- jQuery plugin only in one page/post
- How to create a Page alias in WordPress
- Replace existing pages with new pages, keep menu links
- How to show category images (from plugin) on a regular page (page-example.php)?
- [Plugin: Posts 2 Posts] How does it work?
- How to change ID of an attachment in wp_posts and its related tables correctly?
- Bulk Image Uploader to create new post from each image [closed]
- How use %like% in sql statement wordpress
- Get the url of the full sized attachment image using post ID?
- Adding Attachment Display Settings in custom media frame
- How can i list random post from multiple category?
- Accessing post’s meta data based on user’s click of a post
- View Private Published Page with URL Code (no login required)
- How do I “get the next 10 posts after post_id == x”?
- WordPress page and plugin list using sql query
- Would Gutenberg be considered a PlugIn?
- Making my plugin create a page?
- How can I automatically download all images from all imported posts, place them on my new host, and replace all the links
- Change website directory safely to add a static page on startup
- Delete data from custom table when deleting a post
- Oops! That page can’t be found
- Use get_pages() before another plugin modifies it
- Randomize post (and page) IDs on generation
- Powerpress upload a podcast without creating a post for it
- Failed to load resource: the server responded with a status of 500 () post.php
- How to wrap image tag into div for post only?
- Get content and send to 3rd party
- History of page, interval of years
- Is there any hook to change media html in post? [duplicate]
- How to force regenerate thumbnails in WordPress posts?
- Trending Tags based on post views
- Hidden Some Setting on Post or Page [duplicate]
- Better code/text editing for posts and pages?
- Advanced Custom Fields (ACF) Plugin – Random Image in Sidebar
- Ger posts from similar tags and categories
- Retrieve post thumbnails
- Insert data in custom table during new post creation
- How to make only selected posts appear on a selected wordpress page
- Static page with formatted post list
- Show Similar Post Titles ( Similar to Stack Exchange )
- How do I unlock a post programmatically?
- How to work with Syntax Highlighter Evolved?
- User-Specific Timezones? Hack? Plugin?
- Display (and manage) webcam images?
- Cropping, Re-sizing and Saving images from one folder to another folder in wordpress
- Comparisson between date() and a date from wp_postmeta
- Is there a plugin to display certain posts on certain pages? [closed]
- Converting a simple plugin to be placed inside of functions.php
- Automatically adding post and pages to new blog setups
- How do I create a full-bleed background image on text mouseover? [closed]
- Find unused images?
- Image gallery plugin [closed]
- Not getting author rank when using return
- How can I implement an Add to Collection function on my Image Gallery to be downloaded later?
- How can I restrict image upload dimensions for non-admin WordPress users?
- Add padding while generating thumbnail
- Create page from plugin, but have it completely hidden
- Using AJAX to generate front end / viewer end pages
- How to add subcategories to the blogroll?
- Image Manager Plugin [closed]
- I need help locating a URL that is on my site map, but that I can’t find in my WordPress dashboard
- Show author on every sub-page
- How to Loop Through all Posts and Count Attachments using Get Media Attachments
- Adding Static Image to WooCommerce Content-Single-Product template
- wordpress content .php file in an iframe’s src in a wordpress post
- Error in pdf generating plugin using FPDF
- Return multiple values in a shortcode attribute
- Loop returns the current page’s permalink and guid instead of the post in the loop
- Function added to hook “new_to_publish” not executing – custom plugin
- Creating an admin meta box to save post as pending
- Looking for a photo management solution
- How to find the WordPress Nextgen galleries which are not used in WordPress posts?
- Elementor Pro display featured image on section -> style -> image using shortcode
- Can export gallery but can’t import it Wp all import
- Is there a hook similar to “save_post” which only fires AFTER the post is completely published?
- WordPress Frontend Page using Plugin
- Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /../plugins/rm-payment.php
- Display Multiple Photos as Featured Image when mouse moves on to it post
- Trying to add a new feature in my wordpress website
- automatically set random featured image by category in wordpress on post
- How to disable users to view Other pages
- How can I get the Post ID and Post Type within a Must Use Plugin?
- Does WordPress have a way of changing the ‘Natural’ size of uploaded images?
- Multiple calling javascript from shortcode in one page
- Add new post using a page inside the website
- Plugin does not create a custom table upon activation
- Get page content by ID (from a plugin)
- how to open image gallery in a post/page?
- WordPress filter function using query modifications
- Find And Add Category to Posts
- Get a submitted value from front end post form for single template
- Automatically set posts to NoIndex depending on category?
- How do I hide single category post on my post page
- Windows 10 Printer that Sends to WordPress [closed]
- Want to show pop up image on home page every time when i refresh it [closed]
- How do i display the number of images on the “post screen”
- Set the Social Icon Size in footer