Plugin / Attachment Taxonomies

Felix Arntz

Frequently Asked Questions (FAQ)

As a regular plugin Upload the entire attachment-taxonomies folder to the /wp-content/plugins/ directory or download it through the WordPress backend. Activate the plugin through the ‘Plugins’ menu in WordPress. As a must-use plugin If you don’t know what a must-use plugin is, you might wanna read its introduction in the WordPress Codex – don’t worry, that’s nothing purely for developers. Upload the entire attachment-taxonomies folder to the /wp-content/mu-plugins/ directory (create the directory if it doesn’t exist). Move the file /wp-content/mu-plugins/attachment-taxonomies/attachment-taxonomies.php out of its directory to /wp-content/mu-plugins/attachment-taxonomies.php. Note that, while must-use plugins have the advantage that they cannot be disabled from the admin area, they cannot be updated through WordPress, so you’re recommended to keep them up to date manually. Administration Once the plugin is activated, you will see two new submenu items under Media (Categories and Tags). The plugin follows the WordPress Core philosophy “Decisions, not Options” – therefore there is no additional settings screen. However, the plugin is easily extendable and adjustable by developers (see FAQ). So if the base configuration does not suit your needs, it shouldn’t be too hard to change that.
You can simply use the WordPress Core function register_taxonomy() and specify 'attachment' as the second parameter. As an alternative, you can create your own class for the taxonomy, extending the abstract Attachment_Taxonomy class provided by the plugin. Then you can add it using the method add_taxonomy( $taxonomy ) of the class Attachment_Taxonomies. Example Code (adds an attachment taxonomy called “Location”): __( 'Locations', 'textdomain' ), 'singular_name' => __( 'Location', 'textdomain' ), /* more labels here... */ ); protected $args = array( 'hierarchical' => true, 'query_var' => 'location', /* more arguments here... */ ); } Attachment_Taxonomies::instance()->add_taxonomy( new Attachment_Location() );
To remove one of the default attachment taxonomies you should call the method remove_taxonomy( $taxonomy_slug ) of the class Attachment_Taxonomies. Example Code (removes the attachment taxonomy “Category”): remove_taxonomy( 'attachment_category' );
To accomplish that, first you need to remove the two taxonomies that the plugin adds (attachment_category and attachment_tag). See above for instructions on how to do that. Then you can simply use the WordPress Core function register_taxonomy_for_object_type() and specify 'attachment' as the second parameter. As an alternative, you can create your own instance of the Attachment_Existing_Taxonomy class provided by the plugin. Then you can add it using the method add_taxonomy( $taxonomy, $existing ) of the class Attachment_Taxonomies, with the second parameter set to true. Example Code (makes the regular category and tag taxonomies available for attachments): add_taxonomy( new Attachment_Existing_Taxonomy( 'category' ), true ); Attachment_Taxonomies::instance()->add_taxonomy( new Attachment_Existing_Taxonomy( 'post_tag' ), true );
The [gallery] shortcode can now be passed taxonomy attributes. They have to have the attachment taxonomy slug as the attribute name and a comma-separated list of term slugs or term IDs as value. You may also specify a new “limit” attribute to limit the amount of images shown. This is especially recommended if the attachment taxonomy term you are querying for contains a lot of images. Example Code (shows images with attachment categories 1 or 2 or attachment tag 5 with a limit of 20 images shown): [gallery attachment_category="1,2" attachment_tag="5" limit="20"] Note that there is currently no UI in the backend for this, and the preview in the editor will not work properly. It will show up correctly in the frontend though.
The plugin provides some filters to adjust taxonomy arguments and labels. attachment_taxonomy_args where first argument is the array of taxonomy arguments and the second argument is the taxonomy slug that these arguments apply to attachment_taxonomy_{$taxonomy_slug}_args where the only argument is the array of taxonomy arguments for the taxonomy defined by $taxonomy_slug attachment_taxonomy_labels where first argument is the array of taxonomy labels and the second argument is the taxonomy slug that these labels apply to attachment_taxonomy_{$taxonomy_slug}_labels where the only argument is the array of taxonomy labels for the taxonomy defined by $taxonomy_slug
I preferably take support requests as issues on Github, so I would appreciate if you created an issue for your request there. However, if you don’t have an account there and do not want to sign up, you can of course use the wordpress.org support forums as well.
If you’re a developer and you have some ideas to improve the plugin or to solve a bug, feel free to raise an issue or submit a pull request in the Github repository for the plugin. You can also contribute to the plugin by translating it. Simply visit translate.wordpress.org to get started.

Ratings

4.7
9 reviews

Rating breakdown

Details Information

Version

1.1.1

First Released

30 Jun, 2016

Total Downloads

9,867

Wordpress Version

3.5 or higher

Tested up to:

4.8.11

Require PHP Version:

-

Tags

Contributors

Languages

DIRECTORY DISCLAIMER

The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.