0

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); ?>]?>")

2 Answers 2

1

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.'"]'); ?>
1
  • 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 Commented Oct 31, 2012 at 4:08
0

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.']');
1
  • its not working returning the same code on page Commented Oct 30, 2012 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.