Skip to content

Sort the tags manually in individual posts on wordpress.

License

Notifications You must be signed in to change notification settings

flacoman91/wp-tag-order

 
 

Repository files navigation

WP Tag Order

Latest Stable Version Total Downloads License PHPPackages Rank

WP Tag Order plugin will order tags, non-hierarchical custom-taxonomy terms in individual posts with simple Drag and Drop Sortable capability. And supplies some functions to output it.

Requirements

  • WordPress 4.7+

Installation

  1. cd /path-to-your/wp-content/plugins/
  2. git clone [email protected]:sectsect/wp-tag-order.git
  3. Activate the plugin through the 'Plugins' menu in WordPress.
    That's it 👌

Notes

  • Supports post_tag and non-hierarchical taxonomy.
  • Supports 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" once something one tag.
    Or, if you want to batch apply, Go to Settings -> WP Tag Order page, and click the Apply button.
  • Supports Multisite.
  • Tested on WP v4.7.4

Screenshot

functions

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 Developer

  • 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.

Change log

  • 1.0.1 - Specification change for Wordpress 4.7
  • 1.0.0 - Initial Release

License

See LICENSE file.

About

Sort the tags manually in individual posts on wordpress.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 64.0%
  • JavaScript 22.9%
  • CSS 13.1%