Denoteone
Denoteone

Reputation: 4055

do_shortcode showing as a string in post - WordPress

I have a short code [wtilikepost] that when added to a post will show a like dislike buttons. But I want to add the short code directly to the my template in the PHP I thought I could just

<?php echo do_shortcode( '[wtilikepost]' ); ?>

All that does is output the string "wtilikepost"

Do i need to add something else to my functions.php file?

Upvotes: 1

Views: 614

Answers (1)

Skaparate
Skaparate

Reputation: 489

Try this:

<?php
  if( shortcode_exists( 'wtilikepost' ) )
    do_shortcode( '[wtilikepost]' );
  else
    echo "The shortcode <b>wtilikepost</b> is not installed.";
?>

This way you will be able to know if it's recognized or installed.

Upvotes: 1

Related Questions