Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8749379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:41:08+00:00 2026-06-13T12:41:08+00:00

10/25/2012 – Still Not solved! Please see below: My client has a WordPress Tag

  • 0

10/25/2012 – Still Not solved! Please see below:

My client has a WordPress Tag Cloud (tag array) with tags which include [“] character as well as [The] prefix for some tags. I.e:

"rose"
"autumn"
The Abby
The Cloud
The Elephant

Obviously all the tags enclosed in the quotations marks [“] are sorted on the top of the list and all the words starting with [The] prefix are sorted somewhere around the letter [T] (following the logical ASC order).

It was sprinkled on me that: “All tags (in the WP tag cloud) have to be ordered Ascending but those which contain the [” “] or [The] characters have to be sorted with all other tags in the chronological order, ignoring the [“] and [The] prefix.

I looked into the WP core function:

**function wp_generate_tag_cloud**

but I have no idea where to start. In the raw SQL statement, I could probably use the trim() to filter out the [” “] and [The] characters form the tag cloud array but that is only a thought which I have no idea how to apply.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:41:09+00:00Added an answer on June 13, 2026 at 12:41 pm

    wp_generate_tag_cloud() invokes a filter named tag_cloud_sort, which can override the sort order specified in the $args parameter. The tag_cloud_sort filter receives an array of tags and the actual $args parameter passed to wp_generate_tag_cloud(), so it can inspect the full settings of the wp_generate_tag_cloud() invocation and adjust its behavior accordingly.

    You could try something like this:

    function custom_tag_sort($tags, $args) {
        if ($args['orderby'] != 'name') {
            // do not reorder if sort order is not by name.
            // wp_generate_tag_cloud() is smart enough to notice order
            // is not changed and will proceed with its regular sort logic.
            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) {
        // strip quote marks
        $tag = trim($tag, '"');
        // strip leading definitive article
        $tag = preg_replace('/^\s*the\s+/i', '', $tag);
        return $tag;
    }
    
    add_filter('tag_cloud_sort', 'custom_tag_sort');
    

    Disclaimer: I’ve written this after only a cursory inspection of the wp_generate_tag_cloud() function. I haven’t tested it on a live WordPress installation; I have only verified that the sorting function works correctly on your sample tag cloud:

    The Abby
    "autumn"
    The Cloud
    The Elephant
    "rose"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE 9th june 2012: Setup with mongoid 3.0.0.rc at heroku, see this gist: https://gist.github.com/2900804
I have this string: tag:domain.com,2012-10-12:feed/channel/id/335 Im trying to get the last digits from this
We created a tag 2012/02/16 on our git repository. We then noticed that inside
Does SQL Server 2012 x64 standard edition running on Windows 2008 R2 has LPIM
[05-Mar-2012 02:38:58] PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be
2012-09-07 19:31:07.938 BadgerNew[2590:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not
Enviroment: Visual Studio 2012, MVC4, Razor, Internet Application. I have a JavaScript array.. var
2012 dates are not getting disabled and I cannot figure out why, I've tried
Can I get VS 2012 standard library in VS 2010? VS 2012 has such
UPDATE Feb 10 2012: zOompf has completed some very thorough research on this very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.