Adding attribute to single-product page with functions.php
-
I managed to add images below the tabs in the single project pages for a product category by adding some code to append custom field data from another page to related products section below the tabs. How can I add it to the ‘Additional Information’ tab like an attribute?
add_action( 'woocommerce_related_products_args', 'single_product_patterns', 60 ); function single_product_patterns(){ if ( has_term( 'theterm', 'product_cat' ) ) { $page_id = 2151; $patterns = get_field('patterns',$page_id); $fieldpat = get_field_object('patterns',$page_id); $choicespat = $fieldpat['choices']; if ($patterns) { echo '<ul class="productline_patterns single_page_patterns">'; foreach ($choicespat as $value => $label) { if (in_array($value, $patterns)) { echo '<li><img src="'.get_stylesheet_directory_uri().'/img/pattern/'.$value.'.png">'.$label.'</li>'; } } echo '</ul>'; } } }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Adding attribute to single-product page with functions.php’ is closed to new replies.