WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to display the category slug and not the category name? (5 posts)

  1. TransPersonal
    Member
    Posted 5 years ago #

    I am trying to call the category slug but using this: <?php single_cat_title(); ?> returns the category name. How can I call the slug instead?

    Also how can I call the slug for tags?

  2. TransPersonal
    Member
    Posted 5 years ago #

    Thanks a lot songdogtech!

    The solution I got from the second thread worked perfectly for the category slug:

    <?php
    if (is_category( )) {
    $cat = get_query_var('cat');
    $yourcat = get_category ($cat);
    echo 'the slug is '. $yourcat->slug;
    }
    ?>

    Now if someone can please tell me how to display the tag slug?

  3. Search is your best friend; just a search in the forums of tag and slug revealed this.

  4. TransPersonal
    Member
    Posted 5 years ago #

    Stupid me, I can't believe I missed those threads. I always use google to search wordpress threads - I will remember to use the wordpress search function the next time. Thank you very much for your help songdogtech!

Topic Closed

This topic has been closed to new replies.

About this Topic