The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] Determining Current Category ID (4 posts)

  1. michaelhuang
    Posted 10 years ago #

    Hi. When you display posts by category, how do you find out what the post category is? In other words, how do you determine the number that's after "cat"? Is there a particular function call I could use? I'm trying to add information that depends on the category ID in a sidebar. Thanks!

    ex// http://some.domain.com/index.php?cat=55

  2. nex2nun
    Posted 10 years ago #

    When a category is created it is given an ID which is visible from the Manage -> Categories menu. You can create categories there or create them from a post.

    Hope that helps.

  3. michaelhuang
    Posted 10 years ago #

    Nex, thanks for the reply. Unfortunately, that's not quite what I meant.

    To clarify, I'm trying to display custom category descriptions for the category pages (that appear when you click on a particular category) by changing my sidebar.php. To do this, I need to know the ID of the current category, the one that the user clicked. The function I've been trying to use, get_the_category(), returns all the categories to which a certain category belongs, which doesn't help me.

    Is there any way for me to get that number?

  4. michaelhuang
    Posted 10 years ago #

    Resolved by a friend in a hackish sort of way: steal the number directly from the top using something like $cat_ID = $_GET['cat'];

Topic Closed

This topic has been closed to new replies.

About this Topic