Forums

[resolved] Displaying category name without link (9 posts)

  1. beans_etc
    Member
    Posted 3 years ago #

    I'd like to display simply the name of the category a post belongs to underneath the post title. But when I use <?php the_category(); ?> it automatically makes the name a link. Is there anyway to get rid of the <a href" it puts in so it displays as just text?

  2. moshu
    Member
    Posted 3 years ago #

    Check out the Category Template Tags.
    Template_Tags/#Category_tags

  3. beans_etc
    Member
    Posted 3 years ago #

    I did. There's a similar one "single_cat_title", but it only seems to work if you're on the single page for the category itself. I need it to be able to display the name of the post category, not the current page category.

  4. moshu
    Member
    Posted 3 years ago #

    I said check them ALL, not what you think it should be.
    Template_Tags/get_the_category

  5. moshu
    Member
    Posted 3 years ago #

    And don't ever double post, unless yu want your topics deleted!

  6. beans_etc
    Member
    Posted 3 years ago #

    I thought that one was only used for backend purposes because it says "This function does not display anything". I'm not very php savvy, so I assumed that meant it couldn't be used to show text.

    I'll try this to see if it works, thanks~

  7. beans_etc
    Member
    Posted 3 years ago #

    (Apologies for the double post.)

  8. moshu
    Member
    Posted 3 years ago #

    Don't think, just read:

    The following example displays the category name of each category assigned to the post (this is like using the_category(), but without linking each category to the category view, and using spaces instead of commas):

  9. beans_etc
    Member
    Posted 3 years ago #

    Nice, I just put it the first example from that page as is and it worked! Thanks a lot for the help and clarification~

Topic Closed

This topic has been closed to new replies.

About this Topic