sectsect/wp-tag-order

Sort the tags manually in individual posts on wordpress.


Keywords
plugin, wordpress, order, github, tags, drag-and-drop, sort, terms, wordpress-plugin
License
GPL-3.0+

Documentation

WP Tag Order

Build Status Latest Stable Version composer.lock Total Downloads Latest Unstable Version License

Order tags independently in each posts (not site-globally) on WordPress with simple Drag-and-Drop ↕︎ sortable feature.

⚠️ This plugin is NOT compatible with Gutenberg on WordPress 5.x. Consider using Classic Editor Plugin.

Get Started

  1. Clone this Repo into your wp-content/plugins directory.
$ cd /path-to-your/wp-content/plugins/
$ git clone git@github.com:sectsect/wp-tag-order.git
  1. Activate the plugin through the Plugins menu in WordPress.
  2. Go to Settings -> WP Tag Order page, and select the taxonomies you want to enable.

Features

  • Support post_tag and non-hierarchical taxonomy.
  • Support multiple non-hierarchical taxonomies in a post-type.
  • Support Multisite.

Notes

  • 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 tag once.
    Or, if you want to batch apply to multiple posts,
    Go to Settings -> WP Tag Order page, and click the Apply button in Advance Settings section.
  • Tested on WordPress v6.3.1.

Requirements

  • WordPress 4.7+

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

get_the_tags_ordered()

<?php
$terms = get_the_tags_ordered();
if ( $terms && ! is_wp_error( $terms ) ) :
?>
<ul>
    <?php foreach ( $terms as $term ) : ?>
        <li>
            <a href="<?php echo get_term_link( $term->slug ); ?>">
                <?php echo $term->name; ?>
            </a>
        </li>
    <?php endforeach; ?>
</ul>
<?php endif; ?>

get_the_terms_ordered()

<?php
$terms = get_the_terms_ordered( $post->ID, 'post_tag' );
if ( $terms && ! is_wp_error( $terms ) ) :
?>
<ul>
    <?php foreach ( $terms as $term ) : ?>
        <li>
            <a href="<?php echo get_term_link( $term->slug ); ?>">
                <?php echo $term->name; ?>
            </a>
        </li>
    <?php endforeach; ?>
</ul>
<?php endif; ?>

get_the_tag_list_ordered()

<?php echo get_the_tag_list_ordered(); ?>

get_the_term_list_ordered()

<?php echo get_the_term_list_ordered( $post->ID, 'post_tag' ); ?>

the_tags_ordered()

<?php the_tags_ordered(); ?>

the_terms_ordered()

<?php the_terms_ordered( $post->ID, 'post_tag' ); ?>

Notes for Developers

  • The ordered array of tags is serialized and stored in the wp_postmeta table.

    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