Support » Requests and Feedback » cat_ID in 2.3

  • cat_ID in 2.3 isn’t working right. It seems that category IDs share a place in the database with post IDs. Not only that but the values that are displayed in Manange->categories are not the correct values.

    such that a call to $cat->cat_ID can return the id for a post instead of the id for an actual category.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    category ID’s do not share a place with post ID’s. They both have ID’s, and those ID’s can be the same, but they are not shared between them.

    What are you doing to get $cat->cat_ID? How are you getting $cat, exactly?

    Also, the values in Manage->Categories are indeed correct on my sites. What values are you getting there?

    Thread Starter nthnlsmmrs

    (@nthnlsmmrs)

    <?php
    $category = 1;
    foreach((get_the_category()) as $cat) {
       $cats =  $cat->cat_name . ' ';   if(strstr("$cats", "Free Traffic Systems")  !== FALSE) {
    	$rated_services = true;
    	$category = $cat;
       } else {
    	$category = $cat;
       }
    }
    ?>

    What that does is find out if the current category page is part of the parent category “Free Traffic Systems”. The other category that it comes up with is stored as the actual category.

    Now I can hard code the ID #’s in and I get the same results.

    for instance. One category shows up with an id of 23 (“Safelists”). However, when I make a call to cat_id 23, I get “Banner Exchanges” for some strange reason. I have to call cat_id 24 to get “safelists” to show up.

    The odd thing is that under manage categories the id for Safelists is 23… but when I look in the database under “terms” I can clearly see two entries for safelists. One with an ID of 23 and one with an ID of 24.

    I really don’t know what’s going on there.

    As you can imagine, this is confusing the heck out of me.

    IF the categories are correct for you, have you ever deleted a category? Not one that you just created either, but removed a post or category, or even a page somewhere in the middle… then created another category?

    That seems to be where all my problems started.
    It’s not the theme, I know it’s wordpress.

    Thread Starter nthnlsmmrs

    (@nthnlsmmrs)

    Oh and of course, later on If I want to call the Category ID, I just make a call to $category->cat_ID

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘cat_ID in 2.3’ is closed to new replies.