Created
February 4, 2016 12:14
-
-
Save ambercouch/c6c73594c59fab30aec9 to your computer and use it in GitHub Desktop.
Get only the first category of a post when using get_the_category_list() in your template.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//filters WordPress the_category_list to return onlt the first category. | |
function first_cat($cats) | |
{ | |
return [$cats[0]]; | |
} | |
add_filter('the_category_list', 'first_cat'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment