Closed. This question needs details or clarity. It is not currently accepting answers.admin管理员组文章数量:1291202
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this questionI created a custom metabox for the same woocommerce products, but I would like the community's help so that this metabox appears on the front end.
fuctions.php
add_action( 'woocommerce_product_options_advanced', 'misha_adv_product_options');
function misha_adv_product_options(){
echo '<div class="options_group">';
woocommerce_wp_text_input( array(
'id' => 'misha_plugin_version',
'value' => get_post_meta( get_the_ID(), 'misha_plugin_version', true ),
'label' => 'Plugin version',
'description' => 'Description when desc_tip param is not true'
) );
echo '</div>';
}
add_action( 'woocommerce_process_product_meta', 'misha_save_fields', 10, 2 );
function misha_save_fields( $id, $post ){
//if( !empty( $_POST['super_product'] ) ) {
update_post_meta( $id, 'misha_plugin_version', $_POST['misha_plugin_version'] );
//} else {
// delete_post_meta( $id, 'super_product' );
//}
}
index.php
<?php
$args = array(
'orderby' => 'date',
'post_type' => 'product',
'posts_per_page' => 10,
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
global $product;
echo '<br />
<div class="col">
<div class="card-product">
<a href="'.get_permalink().'">
'.woocommerce_get_product_thumbnail().'
<h1>'.get_the_title().'</h1>
</a>
<a href="**I need the result of my metabox to appear here**">Visualizar demo</a>
</div>
</div>';
endwhile;
wp_reset_query();
?>
本文标签: woocommerce offtopicHow to display the result of a custom metabox in the frontend
版权声明:本文标题:woocommerce offtopic - How to display the result of a custom metabox in the frontend 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741525918a2383463.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论