WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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


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.