- This topic has 3 replies, 3 voices, and was last updated 3 years, 11 months ago by
Tom.
-
AuthorPosts
-
April 7, 2019 at 1:52 am #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.8April 7, 2019 at 5:24 am #861892David
StaffCustomer SupportHi 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: '▪︎'; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/April 7, 2019 at 7:03 am #862064Ali
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.
April 7, 2019 at 4:05 pm #862331Tom
Lead DeveloperLead DeveloperHi there,
I’m not 100% sure what you mean. Can you explain a bit more/link us to an example?
Thanks!
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.