WordPress – unable to display custom meta box values in front end page using shortcode

0
mm
Raghu
Aug 22, 2017 01:13 PM 0 Answers WordPress
Member Since Aug 2017
Subscribed Subscribe Not subscribe
Flag(0)

I am facing problem with my custom meta box values, not able to display values using WordPress shortcode, here my code below

add_shortcode( 'affiliate', 'affliate_shotcode_func' );
function affliate_shotcode_func($atts, $content= null,$post_id)
{

$atts = shortcode_atts( array(
'title' => 'Affiliates',
'count' => 1,
'pagination'=> false
), $atts);

$args= array(

'post_type' => 'mr_joe_affiliates',
'post_status' => 'publish',
'no_found_rows' => $atts['pagination'],
'posts_per_page'=> $atts['count'],
'meta_key' => 'prod_id',

);
$affiliate_display= new WP_Query($args);
if($affiliate_display->have_posts())
{

global $post;

$prod_name= get_post_meta(get_the_ID(),'prod_id',true);

// var_dump($prod_name);

}

//$post=get_post($atts['id']);

$product_name=get_post_meta($post->ID,'prod_id',false);
foreach ( $product_name as $metakey ){
echo $metakey['prod_id'];
// Similarly for all the fields you want to print
}
$product_price=get_post_meta($post_ID,'prod_price',true);
$affiliate_url=get_post_meta($post_ID,'prod_affiliate_url',true);
$affiliate_button_text=get_post_meta($post_ID,'prod_btn_text',true);
$product_summery=get_post_meta($post_ID,'prod_summery',true);
$pros_arr=get_post_meta($post_ID,'repeatable_fields',true);
$pros='';
if(is_array($prod_pros)){
foreach ($prod_pros as $val)
$pros.= '<li>' . $val . '</li>';

}
$cros_arr=get_post_meta($post_ID,'repeatable_cons',true);
$cros='';
if(is_array($prod_cros)){
foreach ($prod_cros as $val)
$cros.= '<li>' . $val . '</li>';

}
var_dump($product_name);
//exit();
$html='<div>
<div>'. $product_name .'</div>

</div>';

return $html;

// return '<div>' . $meta_id['post_id'][0]. '</div>' ;
}

Reply on This
Replying as Submit
1 Subscribers
mm
Submit Answer
0 Answers
Sort By: