Title: get_the_terms
Last modified: August 31, 2016

---

# get_the_terms

 *  [atrag](https://wordpress.org/support/users/atrag/)
 * (@atrag)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/get_the_terms/)
 * I am trying to get the value from a custom taxonomy using get_the_terms. Seems
   like a simple thing but I havent been able to get it to work:
 *     ```
       while ($query4->have_posts() ) : $query4->the_post();
       						if( has_term('' , 'orderIt1' )) {
       								 $theIDforordering2 = get_the_ID();
       							 $firstRandArray = get_the_terms( $theIDforordering2, orderIt1 );
   
       							$secondRandArray = get_the_terms( $theIDforordering2, orderIt2 );
   
       var_dump ($firstRandArray);
       							var_dump ($firstRandArray['"name"']);
   
       } else {echo "";}
       ```
   
 * When I do var_dump for the $firstRand it comes back with this:
 * array(1) { [0]=> object(WP_Term)#3105 (11) { [“term_id”]=> int(32) [“name”]=>
   string(1) “1” [“slug”]=> string(1) “1” [“term_group”]=> int(0) [“term_taxonomy_id”]
   => int(32) [“taxonomy”]=> string(8) “orderIt1” [“description”]=> string(0) “”[“
   parent”]=> int(0) [“count”]=> int(1) [“filter”]=> string(3) “raw” [“object_id”]
   => int(188) } }
 * The custom tag for this post is “1”. So I guess it is under “name”. How do I 
   access that and strip off the string(1) and the quotation marks?
 * I thought I might get it with $firstRandArray[‘”name”‘] or $firstRandArray[‘name’]
   or $firstRandArray->name but all return NULL.

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

 *  [Clarion Technologies](https://wordpress.org/support/users/clarionwpdeveloper/)
 * (@clarionwpdeveloper)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/get_the_terms/#post-7408339)
 * Hello atrag,
 * The $firstRand array also returns the set of array which indexing from 0 to on-
   words so if you want get all the terms assigned to post you have loop through
   the array ‘$firstRandArray’ using ‘for’ loop.
 * OR
    If you want to get single term name value directly you can get by using below:
 *     ```
       $firstRandArray[0]->name ,
       $firstRandArray[1]->name
       ```
   
 *  like this please try you get your result.
 * Thanks
 *  Thread Starter [atrag](https://wordpress.org/support/users/atrag/)
 * (@atrag)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/get_the_terms/#post-7408486)
 * That works great. Thank you.

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

The topic ‘get_the_terms’ is closed to new replies.

## Tags

 * [get_the_terms](https://wordpress.org/support/topic-tag/get_the_terms/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [atrag](https://wordpress.org/support/users/atrag/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/get_the_terms/#post-7408486)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
