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?
- Menu items description? Custom Walker for wp_nav_menu()
- How to define and link full path to css located at a random folder on header.php
- Sizing screenshot.png without losing aspect ratio
- Software for WordPress Theme and Plugin Development? [closed]
- When to use is_home() vs is_front_page()?
- What is the preferred way to add custom javascript files to the site?
- Get the blog page URL set in Options
- How to create .pot files with POedit?
- How do I get the theme URL in PHP?
- Why when I submit a form in wordpress it loads a 404 page though URL is correct
- What is the constant WP_USE_THEMES for?
- Worthwhile to restrict direct access of theme files?
- How Do I Protect My Premium WordPress App Theme from Copying?
- How to detect mobile devices and present them a specific theme?
- Using wp_add_inline_style without a stylesheet
- How to add posts to custom menus?
- WordPress Theme Preview Image
- How To extend WP_Customize_Control
- What is the difference between front-page.php and home.php? [duplicate]
- How can I get page slug
- Does the functions.php file ever get called during an AJAX call? Debug AJAX
- When to use _e and __ for the translation?
- What is a Theme textdomain?
- How to show a custom meta box on the “Quick Edit” screen?
- How to add CSS class to custom logo?
- Broken? WP_Query and “attachment” as a post type
- How to add custom css file in theme?
- How important is it to enqueue a theme’s stylesheet?
- CSS not updating in browser when I change it
- Display Search Result Count
- wp_nav_menu(), how to change class?
- theme path in javascript file
- Is wp_is_mobile() effective?
- Display Menu Name using wp_nav_menu
- Making update notification functionality for my themes
- What questions do you ask when asked to give an estimate on theme development?
- How to remove dashicons.min.css from frontend?
- How do I remove a pre-existing customizer setting?
- Minimum Template Files for Theme Development
- What’s the difference between home.php and index.php?
- pass object/JSON to wp_localize_script
- get_template_part vs action hooks in themes
- Theme Activate Hook
- Solutions for generating dynamic javascript / CSS
- wp_redirect() – headers already sent
- Can I create my own “Recent Posts” widget or customize the existing one?
- Custom single template for a specific category
- how can I add an icon/image for a child theme?
- How can I add a URL field to the attachments window?
- The the_post_thumbnail without srcset?
- The proper way to include/require PHP files in WordPress
- after_setup_theme always runs
- When to use add_action(‘init’) vs add_action(‘wp_enqueue_scripts’)
- Getting failure when using filemtime() with wp_enqueue_style
- Do I actually need to link my theme’s style.css in the theme files
- Why is wp_head() creating a top margin at the top of my theme header?
- How to store widget fields data as an array?
- How do I add version control to my workflow?
- Using classes instead of global functions in functions.php
- WordPress API Menu/Submenu Order
- How can I display a menu on certain pages only?
- Enqueue a stylesheet for login page and make it appear in head element
- Adding a div to wrap widget content after the widget title