WordPress.org

Support

Category ID

  • Hello,
    I need to get the category ID of each post. I was using this code and it used to work:

    $postid=$post->ID;
    $categoriapost=$wpdb->get_var("SELECT term_taxonomy_id FROM wp_term_relationships WHERE object_id=$postid order by term_taxonomy_id asc limit 0,1");}
    $categoriacat = get_query_var('cat');

    Bue now it isn’t working, is there any way to get it in this last version of WP?
    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Category ID’ is closed to new replies.