How reorder post tags taxonomy in the non-alphabetical custom order and save it in the Block Editor

To reorder post tags taxonomy in a non-alphabetical custom order and save it in the Block Editor

To achieve results use a combination of custom code.

// Custom function to fetch tags in custom order
function custom_get_tags($post_id) {
    $tags = get_the_tags($post_id);
    // Modify $tags array to reorder based on custom order
    // Your custom ordering logic here
    return $tags;
}

// Hook into the block editor to modify how tags are displayed
function custom_modify_tag_block($attributes, $content) {
    $post_id = $attributes['postId'];
    $tags = custom_get_tags($post_id);
    // Customize how tags are displayed
    $tag_html="<div class="custom-tag-container">";
    foreach ($tags as $tag) {
        $tag_html .= '<span class="custom-tag">' . $tag->name . '</span>';
    }
    $tag_html .= '</div>';
    return $tag_html;
}
add_filter('render_block_core/tag-cloud', 'custom_modify_tag_block', 10, 2);

// Hook into saving process to save custom tag order
function custom_save_tag_order($post_id) {
    // Fetch tags associated with the post
    $tags = get_the_tags($post_id);
    // Save custom order metadata for each tag
    foreach ($tags as $tag) {
        // Update metadata for custom order
        update_term_meta($tag->term_id, 'custom_order', $custom_order);
    }
}
add_action('save_post', 'custom_save_tag_order');

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)