- Joined
- Apr 7, 2016
- Messages
- 337
- Likes
- 225
- Degree
- 1
I'm trying to show a custom field from a product category on it's child product pages using the Advanced Custom Fields wordpress plugin.
Getting values from another page
https://www.advancedcustomfields.com/resources/code-examples/
Their code example has a variable $other_page = 12; I'm not totally sure what this is. I'm guessing this is the parent category ID.
I'm trying to get the parent subcategory ID with the following:
global $post;
$prod_terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($prod_terms as $prod_term) {
// gets product cat id
$product_cat_id = $prod_term->term_id;
}
So far no luck. Any ideas on what I'm doing wrong?
Getting values from another page
https://www.advancedcustomfields.com/resources/code-examples/
Their code example has a variable $other_page = 12; I'm not totally sure what this is. I'm guessing this is the parent category ID.
I'm trying to get the parent subcategory ID with the following:
global $post;
$prod_terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($prod_terms as $prod_term) {
// gets product cat id
$product_cat_id = $prod_term->term_id;
}
So far no luck. Any ideas on what I'm doing wrong?