I’d like get_the_category_list
to only display one or two categories instead of all the categories associated with the post. Haven’t been able to find any results.
<?php echo get_the_category_list(); ?>
Any help would be appreciated
I’d like get_the_category_list
to only display one or two categories instead of all the categories associated with the post. Haven’t been able to find any results.
<?php echo get_the_category_list(); ?>
Any help would be appreciated
You must be logged in to post a comment.
Quick idea would be to pass some simple separator like comma and cut from the start of result till it.
But I think that if you want better control on output it would make more sense to use level deeper
get_the_category()
function and build markup yourself.This worked. Found in http://codex.wordpress.org/Function_Reference/get_the_category
If you want to limit
get_the_category
to any number you can usebreak;
For example if you want to limit echoing a category + link to show say only 5 categories.