get_term_link() Throwing Error
-
I am using the following code to get the ID number of a term:
<?php $terms = get_the_terms( $post->ID, 'parent-company' ); if ( $terms && ! is_wp_error( $terms ) ) : $parentCompany = array(); foreach ( $terms as $term ) { $termId[] = $term->term_id; } $termId = join( ", ", $termId ); ?>
The value of $termId in this case is just ’70’. And I’m trying to use it like so:
<li><a href="<?php echo get_term_link($termId, 'parent-company'); ?>">View Franchisees:</a></li>
However it gives the following error:
Catchable fatal error: Object of class WP_Error could not be converted to string in...
Whereas if I try :
<li><a href="<?php echo get_term_link(70, 'parent-company'); ?>">View Franchisees:</a></li>
Then it works fine! Does anyone know what I might be doing wrong?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘get_term_link() Throwing Error’ is closed to new replies.