正在寻找查询以获得 meta_value

Looking for query to get meta_value

所以我正在使用 Wordpress、Woocommerce 和 Addify 的“WooCommerce 产品视频”插件。 URL 到 mp4 视频存储在:

wp_postmeta table

在此table中,post_id匹配产品。 在“meta_value”中我可以看到我添加的URL。

没有我的问题; 我想放置一个下载按钮,用于下载存储在此位置的视频。 我找到了按钮需要出现的 woocommerce 挂钩,但我不知道如何从这个 meta_value.

中获取 url

我的代码技能非常基础,所以这对我来说太复杂了。 谁能帮我解决这个问题?

这告诉我 URL 是可见的,但肯定不是最终目标:-)

add_filter( 'woocommerce_share', 'custom_button', 20 );
function custom_button() {
$meta = get_post_meta(get_the_ID(), '', true);
print_r($meta); 

}
  //Here I want to add the button
print '<button>Download video</button>';

谢谢!

'woocommerce_share'挂钩是一个动作,不是过滤器。

试试这个

add_action( 'woocommerce_share', 'custom_button', 20 );
function custom_button() {
    $download_url = get_post_meta(get_the_ID(), 'afpv_cus_featured_video_id', true);

    if ( empty( $download_url ) ) { // do not print anything if download_url doesn't exists
        return;
    }

    // print the download button
    printf( '<a href="%s" class="button" target="_blank" download>%s</a>', 
        esc_url( $download_url ), 
        __( 'Download video', 'text-domain' ) // string can be translated, change text-domain by the theme domain or plugin domain
    );
}