Title: get_term_link() Throwing Error
Last modified: August 20, 2016

---

# get_term_link() Throwing Error

 *  anonymized-3854925
 * (@anonymized-3854925)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/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)

 *  Thread Starter anonymized-3854925
 * (@anonymized-3854925)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/get_term_link-throwing-error/#post-2707401)
 * Never mind, I fixed it with:
    `<li><a href="<?php echo get_term_link(intval($
   termId), 'parent-company'); ?>">View Franchisees:</a></li>`
 *  [Vrunda Pandya](https://wordpress.org/support/users/vrunda-pandya/)
 * (@vrunda-pandya)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/get_term_link-throwing-error/#post-2707547)
 * Hi have same problem, and i try with this solution but it’s not work for me 🙁
   it shows** Catchable fatal error: Object of class WP_Error could not be converted
   to string in /home/jatc**
 *  [Shailesh](https://wordpress.org/support/users/shaileshsavaliya/)
 * (@shaileshsavaliya)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/get_term_link-throwing-error/#post-2707548)
 * use $term->term_id instead $termid.
 *  [bencarter78](https://wordpress.org/support/users/bencarter78/)
 * (@bencarter78)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/get_term_link-throwing-error/#post-2707550)
 * I was just having the same error but I changed it to
 * `get_term_link($term->slug, $term->taxonomy)`
 * All working now.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘get_term_link() Throwing Error’ is closed to new replies.

## Tags

 * [id](https://wordpress.org/support/topic-tag/id/)
 * [link](https://wordpress.org/support/topic-tag/link/)
 * [term](https://wordpress.org/support/topic-tag/term/)

 * 4 replies
 * 4 participants
 * Last reply from: [bencarter78](https://wordpress.org/support/users/bencarter78/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/get_term_link-throwing-error/#post-2707550)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
