WP Tag Order
Order tags (Non-hierarchical custom taxonomies) within individual posts with simple Drag-and-Drop ↕︎ sortable feature.
⚠️ This plugin is NOT compatible with Gutenberg on WordPress 5.x. Consider using Classic Editor Plugin.
Requirements
- WordPress 4.7+
Installation
wp-content/plugins
directory.
1. Clone this Repo into your $ cd /path-to-your/wp-content/plugins/
$ git clone [email protected]:sectsect/wp-tag-order.git
That's it
Features
- Support
post_tag
andnon-hierarchical taxonomy
. - Support multiple
non-hierarchical taxonomies
in a post-type. - In the case of creating a new post, you need to save the post once to activate this feature.
- To apply for the existing post, "Add and Remove" any one tag once.
Or, if you want to batch apply, Go toSettings
->WP Tag Order
page, and click theApply
button. - Support Multisite.
- Tested on WordPress v4.9.
Screencast
APIs
Function | Description |
---|---|
get_the_tags_ordered() |
Based on get_the_tags() - Codex |
get_the_terms_ordered() |
Based on get_the_terms() - Codex |
get_the_tag_list_ordered() |
Based on get_the_tag_list() - Codex |
get_the_term_list_ordered() |
Based on get_the_term_list() - Codex |
the_tags_ordered() |
Based on the_tags() - Codex |
the_terms_ordered() |
Based on the_terms() - Codex |
Usage Example
<h2>get_the_tags_ordered()</h2>
<?php
$posttags = get_the_tags_ordered();
if ( $posttags && ! is_wp_error( $posttags ) ) {
foreach ( $posttags as $tag ) {
echo $tag->name . ' ';
}
}
?>
<h2>get_the_terms_ordered()</h2>
<?php
$posttags = get_the_terms_ordered( $post->ID, 'post_tag' );
if ( $posttags && ! is_wp_error( $posttags ) ) {
foreach ( $posttags as $tag ) {
echo $tag->name . ' ';
}
}
?>
<h2>get_the_tag_list_ordered()</h2>
<?php echo get_the_tag_list_ordered(); ?>
<h2>get_the_term_list_ordered()</h2>
<?php echo get_the_term_list_ordered( $post->ID, 'post_tag' ); ?>
<h2>the_tags_ordered()</h2>
<?php the_tags_ordered(); ?>
<h2>the_terms_ordered()</h2>
<?php the_terms_ordered( $post->ID, 'post_tag' ); ?>
Notes for Developers
-
The sorted tags will be saved in
wp_postmeta
table with an array of tag id that has been serialized as custom field.meta_id post_id meta_key meta_value 19 7 wp-tag-order-post_tag s:91:"a:7:{i:0;s:1:"7";i:1;s:1:"5";i:2;s:2:"10";i:3;s:1:"4";i:4;s:1:"6";i:5;s:1:"8";i:6;s:1:"9";}";
-
This Plugin does not hosting on the wordpress.org repo in order to prevent a flood of support requests from wide audience. Your feedback is welcome.
Change log
See CHANGELOG file.
License
See LICENSE file.
A little project by @sectsect