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
- What is the easiest way to create a custom field archive?
- WP galleries in posts after import. How do I do it?
- Show the author only own types of publications. (JetEngine, Elementor)
- Converting Attachment to Images?
- New post notification plugin [closed]
- Is there plugin to show recent posts from one website in the widget area of another?
- Regenerate images with automatic ALT and TITLE attributes
- Copyright messages for a particular set of pages
- WP_Query do not load specifed number of post
- Show a special message for private page?
- Is it possible to insert images directly from the server?
- Display comments of users on single page
- How can plugins have their own pages?
- wordpress reusable content blocks
- How to add a random image to a post from gallery and only show one?
- Adding Plugin-specific Fields with wp_insert_post()?
- How to add css class to a specific set of images?
- How do I make images clickable so as to enlarge them using lightbox?
- Add a plugin before main container
- medoo framework in WP plugin
- WordPress logo upload option in theme panel
- Accessing GET variable named ‘error’
- Output HTML only on individual post view
- Advanced Custom Fields
- Using the “Latest posts” feature on a different site
- WP_Query ordering numbers as letters
- FacetWP group listings by custom field [closed]
- Post query – show posts from specified day and month and whole years
- Wondering what these multi-colored extra pages are?
- Why isn’t “background-image: url”working with Bootstrap carousel on WP?
- Find unused images?
- Create a custom page template inside my wordpress plugin
- Is there a way to order posts and custom post types as one group?
- Execute a plugin only on post pages
- Support for simultaneous editing
- How to generate video out of images via WordPress plugin
- how do i remove posts from a WP_Query so the pagination is right?
- How to get 1 or 2 specific posts on top of my wordpress blog?
- Portfolio + Blog: multisite or plugin?
- Image gallery plugin [closed]
- WooCommerce shop page orderby [closed]
- How to upload images to WP Panel keeping correct folder in FTP
- Inserting HTML tag with ACF into shortcode
- With W3 Total Cache when I publish a post it does not appear in the homepage. Only if i purge all cache [closed]
- Images not showing after changing wp-content folder name
- Do action only on certain front end pages?
- Preview featured image using frontend post plugin
- How to add an image from web-link?
- Get posts from WP_Query and format them on admin_head
- Best practice for migration friendly images in posts/pages?
- Not getting author rank when using return
- The problem with WordPress Importer
- Cron job not firing
- How to query the custom fields by language?
- How can I implement an Add to Collection function on my Image Gallery to be downloaded later?
- Can I use images as anchor tags with
- Solutions to repost categories into multisite blogs?
- How to enable qTranslate languages tabs in custom plugin page