Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Community,
I am trying to get a specific row from my Wordpress database into the Cart page...
So far i am using this line
<?php $brands = get_terms(); print_r($brands);?>

it gets me a full list with array's like:

[78] => WP_Term Object ( [term_id] => 1 [name] => Uncategorized [slug] => uncategorized [term_group] => 0 [term_taxonomy_id] => 1 [taxonomy] => category [description] => [parent] => 0 [count] => 1 [filter] => raw ) [79] => WP_Term Object ( [term_id] => 142 [name] => USED ITEM [slug] => used-item [term_group] => 0 [term_taxonomy_id] => 142 [taxonomy] => product_brand [description] => [parent] => 0 [count] => 404 [filter] => raw ) 


My goal is to print only this
[name] => USED ITEM
not all other array aswell.

What I have tried:

i have tried to put $brands=>name but it gives me error.
Posted
Updated 1-Apr-17 4:00am
Comments
Member 13099190 1-Apr-17 9:59am    
XML Parsing Error: no root element found Location: https://www.tnpds.gov.in/pages/servicerequest/service-req-form-1.xhtml Line Number 1, Column 1:

<?php 
$terms = get_the_terms( $product_id, 'product_brand' );
foreach ($terms as $term) {
   $product_cat = $term->name;
}
echo '<span style="color:red">'.$product_cat.'</span>'; ?>
 
Share this answer
 
XML Parsing Error: no root element found Location: https://www.tnpds.gov.in/pages/servicerequest/service-req-form-1.xhtml Line Number 1, Column 1:
 
Share this answer
 
Comments
Richard Deeming 4-Apr-17 12:13pm    
And what, exactly, made you think that a random error message with no context constitutes a "solution" to this question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900