Search code examples
wordpresspostshortcodemeta

Wordpress get post meta add shortcode not working


my index post meta code:

<?php echo get_post_meta(get_option('page_on_front'), 'my_post_meta', true); ?>

my shortcode

function shortcode() {
   echo "cesa";
}

if shortcode I run it in content working.

index page echo cesa

but shortcode post meta run with, not working :(

index page only text [shortcode]

please help.


Solution

  • Shortcodes must be parsed, not simply echoed. You can do this by running the the_content filter over it:

    $content = get_post_meta(get_option('page_on_front'), 'my_post_meta', true);
    echo apply_filters( 'the_content', $content );