I'm trying to get the respective category name a single portfolio post belongs to, and paste it into an anchor tag's href attribute. My current code looks like so:
$category = get_the_category($post->ID);
//And little further down the php file...
<a href=" <?php echo get_site_url() . '/' . $category[0]->cat_name) . '/' ?>" />
I've referred to the documentation several times now, and I'd like to know some of your suggestions as my attempts to achieve what I want have ended in little success.
Aucun commentaire:
Enregistrer un commentaire