Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to call custom field in single.php template to complete a short code and thus show a menu.

I places the below code but it is not working

<?php echo do_shortcode("[custommenu menu=<?php echo get_post_meta($post->ID, ‘tabmenu’, true); ?>]?>")
share|improve this question

2 Answers 2

I believe you forgot to add quotes around the menu parameter.

<?php $post_meta_value = get_post_meta($post->ID, 'tabmenu', true);
echo do_shortcode('[custommenu menu="'.$post_meta_value.'"]'); ?>
share|improve this answer
    
This works but he issue is that. I have two menus say MENU0 MENU1. But this code shows Menu0 on every post either I have MENU0 or MENU1 in tabmenu custom field –  Rob Morta Oct 31 '12 at 4:08

Try using this code. Hope this will work.

$post_meta_value = get_post_meta($post->ID, 'tabmenu', true);
echo do_shortcode('[custommenu menu='.$post_meta_value.']');
share|improve this answer
    
its not working returning the same code on page –  Rob Morta Oct 30 '12 at 8:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.