<?php
// Get terms for post
$terms = get_the_terms( $post->ID , 'stores' );
// Loop over each item since it's an array
foreach( $terms as $term ) {
// Print the term_id method from $term which is an OBJECT
// $lovers will be grabs the current store page id
$lovers= $term->term_id;
// Get rid of the other data stored in the object, since it's not needed
unset($term);
}
?>
<?php
$cat_id = $lovers;
$value = get_field('extended_store_descriptions', 'stores_' . $cat_id );
echo $value;
?>
I have a custom taxonomy called stores, so I can't use the code for a standard category as defined here http://codex.wordpress.org/Function_Reference/get_the_category
So I took a look at http://codex.wordpress.org/Function_Reference/get_term_by but can't figure what I need to do.
This is my code
All I need to do is make that number 47 dynamic instead of static and I've tried this:
But that didn't work. I don't know if I should be using this:
http://codex.wordpress.org/Function_Reference/wp_get_post_terms
or this
http://codex.wordpress.org/Function_Reference/get_terms
Thanks so much!
Hopefully some kind soul with the chops can help me out:
When I do this:
It gets me close to what I want:
This is outputted:
Array ( [47] => stdClass Object ( [term_id] => 47 [name] => Amazon.com [slug] => amazon-com [term_group] => 0 [term_taxonomy_id] => 49 [taxonomy] => stores [description] => Amazon Coupon Codes Amazon is the world's largest online retailer. The company also produces consumer electronics, and is a major provider of cloud computing services. [parent] => 0 [count] => 1 [object_id] => 40 ) )
But I only want the number 47 in there
$terms['term_id']
I figured it out with some help from this page: http://wordpress.org/support/topic/trying-to-output-a-posts-terms-taxonomy-as-text-not-urls#post-1188801