Forums

[resolved] Get category that's requested (3 posts)

  1. svaldesm
    Member
    Posted 1 year ago #

    Hey,

    Is there any way to get the category (id or slug) that's requested from wordpress?
    I mean, if I'm watching http://www....../category/animals, is there any way to return "animals" in php? (I want to use it for a special wp_query).

    Thanks,

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    in the archive template (category.php or archive.php):

    <?php $cat_id = get_query_var('cat');
    $cat_slug = get_category($cat_id)->slug; ?>

    untested

  3. svaldesm
    Member
    Posted 1 year ago #

    Thanks a lot, it worked fine.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.