get_the_category_by_id() for custom taxonomy

I have written code that uses get_the_category_by_id() – however I’ve now switched to use a custom taxonomy, and it no longer works.

Here is the code (please note that $settings->select_field is the ID of the particular category, i.e. 23 ):

Read More
$args = array('child_of' => $settings->select_field);
$catname = get_the_category_by_ID( $settings->select_field );

$catname = strtolower($catname);

$catname = str_replace(' ', '-', $catname);

$categories = get_categories( $args );
foreach($categories as $category) { 
    echo '<a class="sub-block block-' . $catname . '" href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>';
}

What is an alternative function I can use

Related posts

1 comment

Comments are closed.