Celil Şahin
Celil Şahin

Reputation: 261

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.

Upvotes: -1

Views: 458

Answers (1)

Hans
Hans

Reputation: 1176

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 );

Upvotes: 1

Related Questions