2
votes

I have created an admin plugin where I wanted to make use of shortcode in plugin file. I did as do_shortcode('[code id=5]'); This is clearly working on post and other positions where it should. But, not working on the plugin. My code:

function applicant_new_form(){
   echo "<h3>Add new application</h3>";
   do_shortcode('[php snippet=3]');   
}

Any Idea?

2
What exactly is the code, could you please write - LIGHT
why do you use echo inside of a function, you should use return inside of a function - David Chase

2 Answers

1
votes

You didn't echo the code, please check. That should be:

function applicant_new_form(){
    echo "<h3>Add new application</h3>";
    echo do_shortcode('[php snippet=3]');
}
0
votes

Is the plugin some kind of widget? If so, try adding:

add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');

to your functions.php file in the root of your theme.