PHP code example of sectsect / wp-tag-order

1. Go to this page and download the library: Download sectsect/wp-tag-order library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sectsect / wp-tag-order example snippets


 echo get_the_tag_list_ordered(); 

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

 the_tags_ordered(); 

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

$tag_updater = new \WP_Tag_Order\Tag_Updater();

try {
    // Update tag order using an array or comma-separated string
    $result = $tag_updater->update_tag_order(
        get_the_ID(),   // Post ID
        'post_tag',     // Taxonomy that enabled in plugin settings
        [1, 2, 3]       // Tag IDs in desired order
    );
} catch ( \InvalidArgumentException $e ) {
    // Error handling
    error_log( $e->getMessage() );
}
 php

$terms = get_the_tags_ordered();
if ( $terms && ! is_wp_error( $terms ) ) :
 php

$terms = get_the_terms_ordered( $post->ID, 'post_tag' );
if ( $terms && ! is_wp_error( $terms ) ) :