Forums

Getting the value of $cat outside the loop (2 posts)

  1. dmclark
    Member
    Posted 7 years ago #

    Hi,

    I'm grappling with a bug in the plugin I released about a week ago http://www.davidsaccess.com/2005/03/13/wp-plugin-dcs-nicer-archives/ having to do with getting the category when is_category is true. I need to get the category.

    If you look at the default themes, Micheal addressed this by forcing $post to be $posts[0]. This does not work for category because $posts[0] can have multiple cats and single_cat_name may not be the right one.

    Any ideas?

  2. Ryan Boren
    WordPress Dev
    Posted 7 years ago #

    If is_category() is true then $cat should be set. You can also try:

    get_query_var('cat')

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.