8,000+
December 30, 2025
November 2, 2009
Extensive usage instructions are available on GitHub
Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types.
The idea behind Attachments is to give developers the ability to directly associate Media items with any post. This is accomplished by adding a meta box to post edit screens as determined by the developer. Once Media items have been associated with a post, you’re able to retrieve those Attachments and include them directly within your template files using any specific markup you wish.
Attachments does not automatically integrate itself with your theme. Since the idea behind Attachments is to allow integration of Media within posts using developer-crafted, unique markup, it’s up to you to integrate with your theme. The most basic integration includes editing the appropriate template file and adding your call(s) to Attachments. For example, if you have set up Attachments to be used with your Posts entries, edit single.php to include the following within The Loop:
<?php $attachments = new Attachments( 'attachments' ); /* pass the instance name */ ?>
<?php if( $attachments->exist() ) : ?>
<h3>Attachments</h3>
<p>Total Attachments: <?php echo $attachments->total(); ?></p>
<ul>
<?php while( $attachments->get() ) : ?>
<li>
ID: <?php echo $attachments->id(); ?><br />
Type: <?php echo $attachments->type(); ?><br />
Subtype: <?php echo $attachments->subtype(); ?><br />
URL: <?php echo $attachments->url(); ?><br />
Image: <?php echo $attachments->image( 'thumbnail' ); ?><br />
Source: <?php echo $attachments->src( 'full' ); ?><br />
Size: <?php echo $attachments->filesize(); ?><br />
Title Field: <?php echo $attachments->field( 'title' ); ?><br />
Caption Field: <?php echo $attachments->field( 'caption' ); ?>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
That snippet will request all of the existing Attachments defined for the current Post within The Loop, and retrieve each itemized property for that Attachment. Using the provided details you’re able to integrate the attached Media items in any way you please.
There is a lot more information on Attachments’ GitHub page. Please contribute!
Please see Attachments on GitHub
Extensive usage instructions are available on GitHub
attachments to your ~/wp-content/plugins/ directoryfunctions.php or your own plugin (see Other Notes > Usage)You will need to update your theme files that use Attachments 3.0. Version 1.x of Attachments has been fully deprecated but is still available and included with Attachments 3.x. If you would like to continue to use the (no longer supported) 1.x version you may add the following to your wp-config.php:
define( 'ATTACHMENTS_LEGACY', true ); // force the legacy version of Attachments
Version 3 is a major rewrite. While I’ve taken precautions in ensuring you won’t lose any saved data it is important to back up your database prior to upgrading in case something goes wrong. This version is a complete rewrite so all legacy data will be left in place, but a migration must take place to match the new data storage model and workflow.
Please see Issues on GitHub
Please see Attachments’ changelog on GitHub
attachments_meta_before_saverewind() method to reset Attachments reference array (props joost de keijzer)post_parent argument support for instances, setting to true will populate the Uploaded to column in Mediaattachments_default_instance to disable/enable the default instance (default is true, ATTACHMENTS_DEFAULT_INSTANCE constant is deprecated)attachments_settings_screen to hide/show the settings screen (default is true, ATTACHMENTS_SETTINGS_SCREEN constant is deprecated)post_type had a dash in itattachments_location_{my_instance} (where **{my_instance}** is your instance name) allows for more fine-grained control over where meta boxes show up (e.g. limiting to your Home page)attachments_extension facilitates Attachments extensionswidth( $size ) to retrieve the width of the current Attachmentheight( $size ) to retrieve the height of the current Attachmenttype method from returninglanguages directory wouldn’t be utilized for l10nmeta_keyfiletype parameter when searching to limit results in that wayattachments_meta_key facilitates using a different meta key for Attachments storageattachments_get_ **{my_instance}** (where **{my_instance}** is your instance name) allows you to filter Attachments per instance once they’ve been retrievedappend => false in your instancesearch() method to allow searching for Attachments based on their attributes (e.g. attachment ID, post ID, post type, field values, etc.)int) of the Attachment you’d like to utilize when firing the method.get_single() method that allows you to specifically retrieve a single Attachmenttotal() method that will return the number of Attachments for the current instanceimage() for a non-image Attachment, the WordPress-defined icon will be returnedicon() method that will return the WordPress-defined icon for the Attachment| Version | Download | Type |
|---|---|---|
| 3.6.10 | Download | Stable |
| 3.5.11 | Download | Stable |
| 3.5.9 | Download | Stable |
| 3.5.7 | Download | Stable |
| 3.5.6 | Download | Stable |
| 3.5.5 | Download | Stable |
| 3.5.4 | Download | Stable |
| 3.5.3 | Download | Stable |
| 3.5.2 | Download | Stable |
| 3.5.1.1 | Download | Stable |
| 3.5.1 | Download | Stable |
| 3.5 | Download | Stable |
| 3.4.2.1 | Download | Stable |
| 3.4.2 | Download | Stable |
| 3.4 | Download | Stable |
| 3.3.3 | Download | Stable |
| 3.3.2 | Download | Stable |
| 3.3.1 | Download | Stable |
| 3.3 | Download | Stable |
| 3.2 | Download | Stable |
| 3.1.4 | Download | Stable |
| 3.1.3 | Download | Stable |
| 3.1.2 | Download | Stable |
| 3.1.1 | Download | Stable |
| 3.1 | Download | Stable |
| 3.0.8.2 | Download | Stable |
| 3.0.8.1 | Download | Stable |
| 3.0.8 | Download | Stable |
| 3.0.7 | Download | Stable |
| 3.0.6 | Download | Stable |
| 1.6.2.1 | Download | Stable |
| 1.6.2 | Download | Stable |
| 1.6.1 | Download | Stable |
| 1.6 | Download | Stable |
| 1.5.10 | Download | Stable |
| 1.5.9 | Download | Stable |
| 1.5.8 | Download | Stable |
| 1.5.7 | Download | Stable |
| 1.5.6 | Download | Stable |
| 1.5.5 | Download | Stable |
| 1.5.4 | Download | Stable |
| 1.5.3.2 | Download | Stable |
| 1.5.3.1 | Download | Stable |
| 1.5.3 | Download | Stable |
| 1.5.2 | Download | Stable |
| 1.5.1.2 | Download | Stable |
| 1.5.1.1 | Download | Stable |
| 1.5.1 | Download | Stable |
| 1.5 | Download | Stable |
| 1.1.1 | Download | Stable |
| 1.1 | Download | Stable |
| 1.0.9 | Download | Stable |
| 1.0.8 | Download | Stable |
| 1.0.7.1 | Download | Stable |
| 1.0.7 | Download | Stable |
| 1.0.5 | Download | Stable |
| 1.0.4.2 | Download | Stable |
| 1.0.4.1 | Download | Stable |
| 1.0.4 | Download | Stable |
| 1.0.3 | Download | Stable |
| 1.0.2 | Download | Stable |
| 1.0.1 | Download | Stable |
| 1.0 | Download | Stable |
| Development | Download | Trunk |