[Support request] Sorting Tag Cloud Widget for Category Taxonomy only

Home Forums Support Sorting Tag Cloud Widget for Category Taxonomy only

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #861817
    Ali

    Hello and thanks for a great theme!

    I am looking for a way to sort arguments in the Tag Cloud Widget for category taxonomy only, not for tag taxonomy. I have two separate tag clouds, one for tag taxonomy and one for category taxonomy. I would like to sort the arguments in the category taxonomy cloud only.

    This is the code I have so far on my test site:

    
    // Sort category list
        function generate_widget_category_cloud_args( $args ) {
    	$exclude = "1,20,21,33,34,35,41,42,43,72"; // Category IDs to be excluded
    	$args["exclude"] = $exclude;
    	$args["orderby"] = 'count';
    	$args["order"] = 'DESC';
    	return $args;
    	}	
    add_filter( 'widget_categories_args', 'generate_widget_category_cloud_args' );// Exclude Categories from Category List
    add_filter( 'widget_tag_cloud_args', 'generate_widget_category_cloud_args' );// Exclude Categories from Tag Cloud Widget
     

    With this code, I’ve managed to sort the tag cloud as I want, but I can’t figure out how to sort only the category taxonomy tag cloud without also sorting the tag taxonomy tag cloud.

    Alternatively, if this is easier, I could find a way to the Categories list widget so that the terms are displayed inline like the Tag cloud widget, and to include a separator between terms, as I’ve done with the Tag cloud widget.

    
    // Tag Cloud format, separators
    add_filter( 'widget_tag_cloud_args', 'generate_widget_tag_cloud_args' );
    function generate_widget_tag_cloud_args( $args ) {
    	$args['largest'] = 12;
    	$args['smallest'] = 12;
    	$args['unit'] = 'px';
    	$args['separator'] = ' ▪︎ ';
    	return $args;
    }
    

    Thanks for you help.

    GP Premium 1.7.8
    #861892
    David
    Staff
    Customer Support

    Hi there

    the alternative option using the Category List widget could be achieved with this simple CSS:

    .widget_categories ul li {
        display: inline;
    }
    
    .widget_categories ul li:not(:last-child):after {
        content: '▪︎';
    }
    #862064
    Ali

    Thanks, that did the trick for the formatting.

    As for the category sort, it seems that the orderby ‘count’ condition is not ordering the category args by frequency. Is there any way to sort the category args by the number of posts applied to each category?

    Thanks again.

    #862331
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    I’m not 100% sure what you mean. Can you explain a bit more/link us to an example?

    Thanks!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.