I have a custom taxonomy "city". I am having a hard time to get cat id. the number. It's also custom post type "job"

This works only for default category under the default post.

  $provinceID = get_cat_ID($cityname);
  echo "<br/>bb=".$provinceID."<br/>";

I have found this one but it's not also working as well. the function name was get_cat_ID and it caused an error. so I have changed name.

  function get_cat_ID11( $cat_name='$cityname' ) {
$cat = get_term_by( 'name', $cat_name, 'category' );
if ( $cat )
    return $cat->term_id;
return 0;

  echo get_cat_ID11;

How can I get the cat id from custom taxonomy , custom post type?

1 Answer 1


I have just found the solution.

I just miss to put a taxonomy name.

     $cat = get_term_by( 'name', $cat_name, 'city' );

this works fine!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.