attachment.php
file displays only one attachment (like single.php
or page.php
).
There is no way to list all attachments without coding. WordPress doesn’t have such list ready to use.
But it’s rather easy to do it by yourself.
Add your custom page template. Assign it to some page. And place something like this inside this template:
$args = array(
'post_type'=>'attachment', // you want to show attachments
'posts_per_page'=>-1, // all of them
// other params
);
$attachments = new WP_Query( $args );
while ( $attachments->have_posts() ): $attachments->the_post();
//display attachment - current attachment is placed in global variable $post
// you can also use template tags
endwhile;
Related Posts:
- Get the first image from post content (eg.: hotlinked images)
- get_attached_media() returns empty array if media file already used by another post
- query posts in wordpress
- Doubled titles when using All in One SEO with custom template
- How can you determine whether an image is merely attached or has actually been inserted into a post?
- posts_nav_link(); not showing up on static pages
- Get attachments by user
- Get list of months with posts
- Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?
- Custom URL parameters in template files
- Metadata Query when storing data as array possible?
- Attach media to multiple posts
- Keep sticky posts out of query unless they have featured image
- attachment.php code or tutorial
- Fetch wordpress video attachment with post ID
- Add attachment for all images in post
- How to query the latest 5 posts and sort them by title?
- Getting Different Size Of Attachment Images
- 2 loops, is_home won’t work, count is off
- How can I prevent posts with no title showing up in my query?
- How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?
- CSS class on last post in loop ( custom query )
- Custom Post Type Query issue
- How to order by multiple date meta_values?
- How to create query to get top 3 sticky/latest posts
- Is There A WordPress Hook for Accessing Attachments for A Particular Page?
- WP_Query not getting all posts, just tagged posts
- tag__in does not return posts
- multiple queries to get posts from same category?
- Theming media inserts
- Best practice for implementing a blog page / section in wp_menu_nav()
- How to store and retrieve the attachment alignment?
- Change default options on attachment page
- Not the typical order by posts by date question
- Paginated WP_Query doesn’t return 404’s, even when posts don’t exist
- issue displaying variations in custom template using WPeC 3.8.9.2
- How to force unlink on attached/inserted images?
- How To Add New Option Types To Option Tree?
- Trigger Customizer saving process with Javascript only
- Comment form not display properly?
- How to add menu support to a theme?
- Moving functionality from functions.php to classes?
- Registering Sidebars and Sidebar Widgets. Sidebar Widgets Not Displaying
- Extend walker – navigation, adding data attribute to a tag
- How to display category specific post content on a page
- Gutenberg Reusable Block as part of WordPress Theme page
- Why is $GLOBALS[‘content_width’] needed if site is responsive?
- Does WordPress count as a means to learn web development? [closed]
- current-menu-item class not working
- Prevent theme from activating [duplicate]
- Messing up with transient API – getting flushed on refresh
- Correctly using wp_head()
- Cannot figure out how to overwrite files in child theme
- Inheritance of parent theme plugin files in a child theme
- Display a list of certain categories by ID
- Implementing FancyBox
- Single Page Design, Storing in Theme Options
- How to append to menu items selectively
- Working with a WP Starter theme
- Should I change text-domain of TGM library inside theme?
- tag is being auto inserted
- “Bad element for masonry: undefined” why this error us occuring? [closed]
- Scroll to position on page for category pages only — woocommerce
- Displaying details of a post in a sidebar
- Multi-page posts: A subdirectory for each post?
- How do I get the trackback count of a post in wordpress without writing an SQL query?
- Call to require(‘../../../wp-blog-header.php’) results in 404 error?
- Where do files uploaded via Media Manager get stored in MU?
- How to add menù section to my WordPress template?
- customize theme with get_template_part() [closed]
- How to add post meta fields to an article’s as meta elements
- Callback Function Not Firing On Selection In Media Uploader
- How add built-in textarea in theme development?
- Pagination fuction in shortcode always displays on top
- Add content after get_header
- Get video from the post on homepage
- WordPress Themes Directory: Template which hits the standards?
- Get next and prev item from custom WP_Query and Custom Post Type
- get_avatar() is not working in my custom theme
- When I save changes for css and js in my WP localhost env windows 10 the changes don’t take effects immediately!
- makeing a terms of use page that is part of the theme
- Global page ID variable empty error
- Different templates for each category level
- Child theme in separate WordPress Install
- Display problems in admin dashboard when creating a new theme from scratch
- Using Customizer value in an external PHP file inside a theme
- How to add drop symbol to parent nav items which have child
- WP_Query for attachments without duplicating post_parent and displaying tagged image
- Enqueue Stylesheets After Theme’s “rtl.css”
- WordPress 3.5 + Foundation 5 not working on IE9
- Using wp_enqueue_script with social media buttons?
- Want to include ad code after related post
- How can disable function wp_link_dialog()
- Pagination adds product to cart Woo-Commerce
- Onepage with shortcodes
- How to create full header but keep content narrow
- My wordpress site memory exhausted more than 1GB trying to debug with default
- Display first post on each page differently than the others
- Custom Theme functions.php – Using add_settings_field and input type=”file” to set custom logo
- Image and font support missing in editor when deploying theme remotely