get the category slug of a post
-
within a loop i’m retrieving the category slug of a post with this code:
$category = get_the_category();
$kat = $category[0]->category_nicename;the problem starts when a post belongs to more than one category. wordpress permalinks are made with the category slug that has the lowest cat id. my example seems to return the category slugs alphabetically.
how can i just get the slug with the lowest id?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘get the category slug of a post’ is closed to new replies.