How would I go about creating a custom function or adding an array to the current wp_list_categories function to display categories with x amount of numbers and above. I have a lot of categories so I want to limit it to the more popular categories.
How would I go about creating a custom function or adding an array to the current wp_list_categories function to display categories with x amount of numbers and above. I have a lot of categories so I want to limit it to the more popular categories.
Not sure how to set a specific number, but you can set it to order by count. So I'd set it up to order by count and then limit the number it returns. This will get you a list of categories with the most posts in them.
<?php wp_list_categories('orderby=count&number=10'); ?>
Thanks for your reply. That's what I'm doing right now as a fallback, but essentially I'd like this function because I still want to maintain the alphabetical order listing of the categories rather than by count.
In that case I'd use get_categories, which is essentially the same only it doesn't format or display any results, just saves them in an array.
You can then take that array and sort it, and output it how you want.
Something like this:
$categories = get_categories('orderby=count&number=10');
sort($categories);
foreach ($categories as $category) {
<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>
}You must log in to post.