2014-06-28 12:47
浏览 65


I've created a custom metabox using this example. When the admin-user enters a shortcode in my metabox, the shortcode displays on my front-end as plain text such as:


How can I make sure WordPress parses the shortcode so an actual menu is outputted?

I'm using this in my page.php template to display the contents of my custom metabox:

echo get_post_meta( get_the_ID(), '_my_custom_meta_value_key', true );

图片转代码服务由CSDN问答提供 功能建议

我使用此示例。 当admin-user在我的metabox中输入短代码时,短代码会在我的前端显示为纯文本 例如:


如何确保WordPress解析短代码以便 输出实际菜单?


   echo get_post_meta(get_the_ID(),'_ my_custom_meta_value_key',true); 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongluo9156 2014-06-28 13:00

    You can simply use do_shortcode provided by WordPress. This can be used to manually search through the given string for shortcodes.

    According to docs for do_shortcode:

    Searches content for shortcodes and filters shortcodes through their hooks.

    This is how you can do it:

    $shortcode = get_post_meta( get_the_ID(), '_my_custom_meta_value_key', true );
    echo do_shortcode($shortcode);
    解决 无用
    打赏 举报

相关推荐 更多相似问题