• Resolved fatalx

    (@fatalx)


    Hello,

    I created a custom post type that has its own custom taxonomy. I wanted to used get_cat_id and get_cat_name to get ID’s and names from that taxonomy but those two function only looks at the main Categories under the default posts.

    are there simple functions like this for custom taxonomy?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • http://codex.wordpress.org/Function_Reference/get_term_by

    here is the example how ‘get_cat_id()’ for instance works with the above function ( from /wp-includes/category.php )

    /**
     * Retrieve the ID of a category from its name.
     *
     * @since 1.0.0
     *
     * @param string $cat_name Optional. Default is 'General' and can be any category name.
     * @return int 0, if failure and ID of category on success.
     */
    function get_cat_ID( $cat_name='General' ) {
    	$cat = get_term_by( 'name', $cat_name, 'category' );
    	if ( $cat )
    		return $cat->term_id;
    	return 0;
    }

    Thread Starter fatalx

    (@fatalx)

    Awesome, Thanks alchymyth that’s exactly what I needed.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using get_cat_id and get_cat_name on custom taxonomy?’ is closed to new replies.