Support » How-To and Troubleshooting » get current ID allways returns "1"

get current ID allways returns "1"

  • I have found a function on the web that seems to be working for many people, but for me it doesn’t. It allways returns “1”, the ID number of the uncategorized category, while I’m not in that category.

    This is the code:

    function getCurrentCatID(){
    global $wp_query;
    if(is_category() || is_single()){
    $cat_ID = get_query_var(‘cat’);
    return $cat_ID;

    I need the current category ID number for adjusting a category filter widget. Which only needs to show the subcategories of the current parent category…

    I’m not a hero in programming php, but I know the basics…
    so any help would be greatly appreciated!

  • The topic ‘get current ID allways returns "1"’ is closed to new replies.