WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] is_category() and is_tag() : how to get the category then (3 posts)

  1. willx
    Member
    Posted 2 years ago #

    Imagine
    You're on a website, and it's currently showing a category page.

    Thus, is_category() returns true...
    ==> Question: how to get THE category which is being displayed?

    Imagine
    You're on a website, and it's currently showing a tag page.

    Thus, is_tag() returns true...
    ==> Question: how to get THE tag(s) which is/are being displayed?

    Noobie question but I need it =)

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

    how to get THE category which is being displayed

    to get the category id:

    get_query_var('cat')

    to get/output the category title:

    single_cat_title()

    http://codex.wordpress.org/Function_Reference/single_cat_title

    how to get THE tag(s) which is/are being displayed?

    to get the tag slug:

    get_query_var('tag')

    to get the tag title:

    single_tag_title()

    http://codex.wordpress.org/Function_Reference/single_tag_title

    or also:
    single_cat_title()

  3. willx
    Member
    Posted 2 years ago #

    Exactly what I was looking for.

    Thank you.

Topic Closed

This topic has been closed to new replies.

About this Topic