• Resolved svaldesm

    (@svaldesm)


    Hey,

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

    Thanks,

Viewing 2 replies - 1 through 2 (of 2 total)
  • Michael

    (@alchymyth)

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

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

    untested

    Thread Starter svaldesm

    (@svaldesm)

    Thanks a lot, it worked fine.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get category that's requested’ is closed to new replies.