How would I go about pulling the most popular (most used) categories?
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
I am trying to use WordPress' built in function for calling a list of categories. Unfortunately there doesn't appear to be an argument for how to pull the most popular categories (say top 5). I am using the code below which is pulling in all categories. Any idea on how I could modify this to display the top 5 most used categories?
<?php
$args = array(
'show_option_all' => '',
'orderby' => 'name',
'order' => 'ASC',
'style' => 'list',
'show_count' => 0,
'hide_empty' => 1,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => '',
'feed_type' => '',
'feed_image' => '',
'exclude' => '1',
'exclude_tree' => '',
'include' => '',
'hierarchical' => 1,
'title_li' => __( '' ),
'show_option_none' => __( '' ),
'number' => 5, // limits the number of displayed categories
'echo' => 1,
'depth' => 0,
'current_category' => 0,
'pad_counts' => 0,
'taxonomy' => 'category',
'walker' => null,
);
wp_list_categories( $args );
?>
categories get-categories wp-list-categories
New contributor
Peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
1
down vote
favorite
I am trying to use WordPress' built in function for calling a list of categories. Unfortunately there doesn't appear to be an argument for how to pull the most popular categories (say top 5). I am using the code below which is pulling in all categories. Any idea on how I could modify this to display the top 5 most used categories?
<?php
$args = array(
'show_option_all' => '',
'orderby' => 'name',
'order' => 'ASC',
'style' => 'list',
'show_count' => 0,
'hide_empty' => 1,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => '',
'feed_type' => '',
'feed_image' => '',
'exclude' => '1',
'exclude_tree' => '',
'include' => '',
'hierarchical' => 1,
'title_li' => __( '' ),
'show_option_none' => __( '' ),
'number' => 5, // limits the number of displayed categories
'echo' => 1,
'depth' => 0,
'current_category' => 0,
'pad_counts' => 0,
'taxonomy' => 'category',
'walker' => null,
);
wp_list_categories( $args );
?>
categories get-categories wp-list-categories
New contributor
Peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am trying to use WordPress' built in function for calling a list of categories. Unfortunately there doesn't appear to be an argument for how to pull the most popular categories (say top 5). I am using the code below which is pulling in all categories. Any idea on how I could modify this to display the top 5 most used categories?
<?php
$args = array(
'show_option_all' => '',
'orderby' => 'name',
'order' => 'ASC',
'style' => 'list',
'show_count' => 0,
'hide_empty' => 1,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => '',
'feed_type' => '',
'feed_image' => '',
'exclude' => '1',
'exclude_tree' => '',
'include' => '',
'hierarchical' => 1,
'title_li' => __( '' ),
'show_option_none' => __( '' ),
'number' => 5, // limits the number of displayed categories
'echo' => 1,
'depth' => 0,
'current_category' => 0,
'pad_counts' => 0,
'taxonomy' => 'category',
'walker' => null,
);
wp_list_categories( $args );
?>
categories get-categories wp-list-categories
New contributor
Peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I am trying to use WordPress' built in function for calling a list of categories. Unfortunately there doesn't appear to be an argument for how to pull the most popular categories (say top 5). I am using the code below which is pulling in all categories. Any idea on how I could modify this to display the top 5 most used categories?
<?php
$args = array(
'show_option_all' => '',
'orderby' => 'name',
'order' => 'ASC',
'style' => 'list',
'show_count' => 0,
'hide_empty' => 1,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => '',
'feed_type' => '',
'feed_image' => '',
'exclude' => '1',
'exclude_tree' => '',
'include' => '',
'hierarchical' => 1,
'title_li' => __( '' ),
'show_option_none' => __( '' ),
'number' => 5, // limits the number of displayed categories
'echo' => 1,
'depth' => 0,
'current_category' => 0,
'pad_counts' => 0,
'taxonomy' => 'category',
'walker' => null,
);
wp_list_categories( $args );
?>
categories get-categories wp-list-categories
categories get-categories wp-list-categories
New contributor
Peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 4 hours ago
Peter
153
153
New contributor
Peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
You can order by count
to order them by the number of posts they are attached to. Use number
to limit the number of terms returned:
wp_list_categories( [
'orderby' => 'count',
'order' => 'DESC',
'number' => 5
] );
Wow I am feeling very humbled right now. I looked at the WP documentation for this function and missed this. Thank you!
– Peter
4 hours ago
Don't feel so bad, I don't thinkcount
is listed anywhere as a valid value fororderby
, you have to look at the documentation for the genericget_terms
to see that it's possible to do this.
– Milo
4 hours ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You can order by count
to order them by the number of posts they are attached to. Use number
to limit the number of terms returned:
wp_list_categories( [
'orderby' => 'count',
'order' => 'DESC',
'number' => 5
] );
Wow I am feeling very humbled right now. I looked at the WP documentation for this function and missed this. Thank you!
– Peter
4 hours ago
Don't feel so bad, I don't thinkcount
is listed anywhere as a valid value fororderby
, you have to look at the documentation for the genericget_terms
to see that it's possible to do this.
– Milo
4 hours ago
add a comment |Â
up vote
2
down vote
accepted
You can order by count
to order them by the number of posts they are attached to. Use number
to limit the number of terms returned:
wp_list_categories( [
'orderby' => 'count',
'order' => 'DESC',
'number' => 5
] );
Wow I am feeling very humbled right now. I looked at the WP documentation for this function and missed this. Thank you!
– Peter
4 hours ago
Don't feel so bad, I don't thinkcount
is listed anywhere as a valid value fororderby
, you have to look at the documentation for the genericget_terms
to see that it's possible to do this.
– Milo
4 hours ago
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You can order by count
to order them by the number of posts they are attached to. Use number
to limit the number of terms returned:
wp_list_categories( [
'orderby' => 'count',
'order' => 'DESC',
'number' => 5
] );
You can order by count
to order them by the number of posts they are attached to. Use number
to limit the number of terms returned:
wp_list_categories( [
'orderby' => 'count',
'order' => 'DESC',
'number' => 5
] );
answered 4 hours ago
Milo
64.2k273108
64.2k273108
Wow I am feeling very humbled right now. I looked at the WP documentation for this function and missed this. Thank you!
– Peter
4 hours ago
Don't feel so bad, I don't thinkcount
is listed anywhere as a valid value fororderby
, you have to look at the documentation for the genericget_terms
to see that it's possible to do this.
– Milo
4 hours ago
add a comment |Â
Wow I am feeling very humbled right now. I looked at the WP documentation for this function and missed this. Thank you!
– Peter
4 hours ago
Don't feel so bad, I don't thinkcount
is listed anywhere as a valid value fororderby
, you have to look at the documentation for the genericget_terms
to see that it's possible to do this.
– Milo
4 hours ago
Wow I am feeling very humbled right now. I looked at the WP documentation for this function and missed this. Thank you!
– Peter
4 hours ago
Wow I am feeling very humbled right now. I looked at the WP documentation for this function and missed this. Thank you!
– Peter
4 hours ago
Don't feel so bad, I don't think
count
is listed anywhere as a valid value for orderby
, you have to look at the documentation for the generic get_terms
to see that it's possible to do this.– Milo
4 hours ago
Don't feel so bad, I don't think
count
is listed anywhere as a valid value for orderby
, you have to look at the documentation for the generic get_terms
to see that it's possible to do this.– Milo
4 hours ago
add a comment |Â
Peter is a new contributor. Be nice, and check out our Code of Conduct.
Peter is a new contributor. Be nice, and check out our Code of Conduct.
Peter is a new contributor. Be nice, and check out our Code of Conduct.
Peter is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f316288%2fhow-would-i-go-about-pulling-the-most-popular-most-used-categories%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password