Which of the following codes is correct for sorting tags of the "WordPress Tag Cloud", when those tags contain special characters?
Answer
Correct Answer: function custom_tag_sort($tags, $args) { if ($args['orderby'] != 'name') { return $tags; } uasort($tags, 'custom_tag_sort_compare'); } function custom_tag_sort_compare($a, $b) { return strnatcasecmp( custom_tag_sort_normalize($a->name), custom_tag_sort_normalize($b->name) ); } function custom_tag_sort_normalize($tag) { $tag = trim($tag, '"'); $tag = preg_replace('/^\s+the\s+/i', '', $tag); return $tag; } add_filter('tag_cloud_sort', 'custom_tag_sort');
Explanation:
Note: This Question is unanswered, help us to find answer for this one