dongshao9106 2016-02-01 14:21 采纳率: 100%
浏览 67

如何从变量产品中获取属性?

I have variable product with attribute URL that is used for variations.

I need to display it on page but I dont know how. I tried many ways but nothing was OK. For example this code:

echo get_post_meta($value['variation_id'], 'attribute_pa_url', true);

returns url like "httpwww-domain-comsometthingsomethingelse" instead of "http://www.domain.com/sometthing/somethingelse"

Any hint what I should do? Thank you!

  • 写回答

1条回答 默认 最新

  • doudouwd2017 2016-02-01 14:48
    关注

    That worked:

    $taxonomy = 'pa_color';
    $meta = get_post_meta($value['variation_id'], 'attribute_'.$taxonomy, true);
    $term = get_term_by('slug', $meta, $taxonomy);
    echo $term->name;
    

    Thanks to Reigel!

    评论

报告相同问题?