php code to link a category
-
Hello
I’m trying to make a dynamical link to a categorie but i guess i’m doing something wrong,
My posts usually got 2 categories : a ‘Support’ and a ‘Genre’
and ‘Genre’ got sub categories..I was trying to get a display like this:
“Details : genre”
and when you clicked on the genre it’ll link you to the posts with the similar genreAt first I wrote in the single.php:
<p>Details : <?php $category = get_the_category();?>cat_ID; ?>”><?php echo $categories[1]->cat_name; ?></p>But if it worked well in some case, in others it doesn’t :
let’s say for a post my categories are : Nes, Strategy
It’s ok as the $category[1] will be strategyBut if i Got : Beat’em all, Nes
the category[1] will be Nes, because the cats in WP are listed in alphabetical orderSo how can I say to link to the “Genre” and its sub categories ?
The topic ‘php code to link a category’ is closed to new replies.