sectsect / wp-tag-order
Sort the tags manually in individual posts on wordpress.
Installs: 332
Dependents: 0
Suggesters: 0
Security: 0
Stars: 20
Watchers: 3
Forks: 3
Open Issues: 1
Type:wordpress-plugin
Requires
- php: >=8.0
Requires (Dev)
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^7.5 || ^9.5
- squizlabs/php_codesniffer: ^3.7
- szepeviktor/phpstan-wordpress: ^1.3
- wp-coding-standards/wpcs: ^3.0
- yoast/phpunit-polyfills: ^2.0
- dev-master
- v3.9.5
- v3.9.4
- v3.9.3
- v3.9.2
- v3.9.1
- v3.9.0
- v3.8.2
- v3.8.1
- v3.8.0
- v3.7.2
- v3.7.1
- v3.7.0
- v3.6.0
- v3.5.0
- v3.4.1
- v3.4.0
- v3.3.0
- v3.2.0
- v3.1.0
- v3.0.0
- v2.2.5
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.0
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.9
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-feature/rest-api
- dev-php7
- dev-feature/code-coverage
- dev-feature/type-hinting
- dev-feature/migration-ci
This package is auto-updated.
Last update: 2024-11-23 07:21:27 UTC
README
Order tags independently in each posts (not site-globally) on WordPress with simple Drag-and-Drop ↕︎ sortable feature.
Important
This plugin is NOT compatible with Gutenberg on WordPress 5.x. Consider using Classic Editor Plugin.
Important
Mutation events will no longer be supported in Google Chrome and Edge in July 2024 (Google Chrome on July 23, 2024, and Microsoft Edge the week of July 25, 2024).
As a result, WP Tag Order versions 3.6.0 or less will not work with Chrome v127 and later, which will be released on July 23, 2024.
You have to update to v3.7.0 or later.
If you still need PHP7 support, see Troubleshooting below.
See Chrome for Developers Blog for more details.
Get Started
- 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
- Activate the plugin through the
Plugins
menu in WordPress. - Go to
Settings
->WP Tag Order
page to select which taxonomies to enable ordering for.
Features
- 🏷️ Custom tag ordering for posts
- 🔍 Works with default WordPress tag and custom taxonomy systems
- 🔢 Drag-and-Drop interface for easy tag reordering
- 📊 Supports multiple post types and taxonomies
- 🌐 NEW: REST API Support
- Retrieve ordered tags via GET endpoint
- Update tag order programmatically
- Supports authentication and permissions
- 🚀 Lightweight and performance-optimized
Notes
- When creating a new post, you need to save it once to enable tag ordering.
- To apply ordering to existing posts, "Add and Remove" any tag once.
- To bulk-update multiple posts at once, go to
Settings
->WP Tag Order
page and click 'Apply' under the Advanced Settings.
- Tested on WordPress v6.3.1.
Requirements
- WordPress 5.6+
- PHP 8.0+
APIs
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, 'post_tag' ); ?>"> <?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, 'post_tag' ); ?>"> <?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' ); ?>
REST API
The WP Tag Order plugin provides two REST API endpoints for managing tag order:
Get Tag Order
- Endpoint:
/wp-json/wp-tag-order/v1/tags/order/{post_id}
- Method:
GET
- Parameters:
post_id
(required): The ID of the posttaxonomy
(optional): Taxonomy name (defaults to 'post_tag')
- Permissions: Publicly accessible
- Response: Array of ordered tags with full term details
Example Request
GET /wp-json/wp-tag-order/v1/tags/order/123
w/ cURL
curl --location 'https://your-wordpress-site.com/wp-json/wp-tag-order/v1/tags/order/123'
Update Tag Order
- Endpoint:
/wp-json/wp-tag-order/v1/tags/order/{post_id}
- Method:
PUT
orPATCH
- Parameters:
post_id
(required): The ID of the posttaxonomy
(required): Taxonomy nametags
(required): Comma-separated list of tag IDs in desired order
- Permissions: Requires user authentication and post edit capabilities
- Response: Success status and message
Example Request
PUT /wp-json/wp-tag-order/v1/tags/order/123
{
"taxonomy": "post_tag",
"tags": "5,3,1,4,2"
}
w/ cURL
curl --location --request PUT 'https://your-wordpress-site.com/wp-json/wp-tag-order/v1/tags/order/123' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_JWT_TOKEN' \ --data '{ "taxonomy": "post_tag", "tags": "5,3,1,4,2" }'
Example Response
{ "success": true, "code": "tags_order_updated", "message": "Tag order updated successfully.", "data": { "status": 200, "post_id": 123, "taxonomy": "pickup_tag", "tags": [ 5, 3, 1, 4, 2 ] } }
Authentication
- GET requests are publicly accessible
- PUT/PATCH requests require:
- User to be logged in
- User to have edit permissions for the specific post
- Post must be of an allowed type (default: 'post' or 'page')
For Developers
-
The ordered tag data is serialized and stored in the
wp_postmeta
table under keys likewp-tag-order-{taxonomy}
. -
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.
Troubleshooting
Still need support for PHP 7.
I have a branch php7 to support PHP 7 and End-of-Life for JaveScript Mutation events.
The branch will not be maintained anymore, so I recommend you migrate to PHP 8.
Change log
See CHANGELOG file.
License
See LICENSE file.
✌️
A little project by @sectsect