• I’m trying to display the category as a link to archive.php and not as a list item. The code I have lists the category, but I’m not sure how to link it up to the archive page.

    Category: <a href=""><?php
    $category = get_the_category();
    echo $category[0]->cat_name;
    ?></a>
Viewing 3 replies - 1 through 3 (of 3 total)
  • J M

    (@hiphopinenglish)

    get_category_link should do the trick. See here.

    Thread Starter navyspitfire

    (@navyspitfire)

    I’m a bit confused by that example. I want each blog entry to display its respective category and be a link to that categories archive page. I don’t understand this line:

    $category_id = get_cat_ID( 'Category Name' );

    Is that supposed to be specific to a category I write in myself, or will be specific to whatever category I choose for the post?

    J M

    (@hiphopinenglish)

    Sorry for a late reply. You’ve already got the category in your original code. It’s now stored in $category.

    You should be able to use the second line of the get_category_link example in the link above, and call $category.
    Something like this:
    $category_link = get_category_link( $category );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display category as link to archive and not in list item’ is closed to new replies.