Я пытаюсь вставить значения атрибута товара на странице в виде ссылки. На странице «stilart» я хотел бы вставить значения продукта дань «stilart» в виде ссылок на значения. Например. значение "джаз" должно ссылаться на /stilart/jazz.
вот что у меня есть:
add_action( 'storefront_page', 'vis_stilarter' );
if ( is_page(stilart) && $post->post_parent > 0 ) {
function vis_stilarter() {
global $post;
$attribute_names = array( 'pa_stilart' ); // Add attribute names here and remember to add the pa_ prefix to the attribute name
foreach ( $attribute_names as $attribute_name ) {
$taxonomy = get_taxonomy( $attribute_name );
if ( $taxonomy && ! is_wp_error( $taxonomy ) ) {
$terms = wp_get_post_terms( $post->ID, $attribute_name );
$terms_array = array();
if ( ! empty( $terms ) ) {
foreach ( $terms as $term ) {
$archive_link = get_term_link( $term->slug, $attribute_name );
$full_line = '<a href="' . $archive_link . '">'. $term->name . '</a>';
array_push( $terms_array, $full_line );
}
echo '<li class="stilart">'.$taxonomy->labels->singular_name . ' ' . implode( $terms_array, ', ');
}
}
}
}}