I am creating a small plugin where I am creating a few shortcodes. I am using Classic Editor plugin.

Here is my code in Plugin.php:

 * Plugin Name: Simple Data Visualizer
 * Description: Reads data from CSV and displays data in required format
 * Version: 1.0.0
 * Author: Subrata

function evd_dreambig_shortcode() {
    return 'Hello! Can you dream big?';

function register_evd_shortcodes() {
    add_shortcode( 'dream-big', 'evd_dreambig_shortcode' );

add_action( 'init', 'register_evd_shortcodes' );

But when I put the shortcode in Post content as [dream-big], it is only rendering the tag, i.e. [dream-big] on post page rather than showing its content: Hello! Can you dream big?

I also took a different approach:

function evd_dreambig_shortcode() {
    return '<h1>Hello! Can you dream big?</h1>';

add_shortcode( 'dream-big', 'evd_dreambig_shortcode' );

But this does not work either.

I am using a custom theme. I also tried by adding add_filter( 'the_content', 'do_shortcode'); in functions.php. Still no luck!

plugin.php is the only file in my plugin directory.

What I am doing wrong?

  • Your exact code works perfectly for me. Is the plugin definitely active? Where are you placing the shortcode? In the visual editor? Does your theme template use the the_content() function? Commented Oct 2, 2019 at 7:42
  • Would you please mind explaining a bit more? Commented Oct 2, 2019 at 9:39
  • Have you activated the plugin in Plugins > Installed Plugins? And where in WordPress are you typing the shortcode? I don't know what else you want me to explain. Commented Oct 2, 2019 at 10:24
  • Oh yes! Of course I activated the plugin. And I am writing the shortcode in the editor (classic editor. not using block editor). The shortcode content is only coming after adding apply_filters( 'the_content', $post->post_content ); in single post page. Don;t don't why I am needing this. Commented Oct 2, 2019 at 10:54
  • 1
    Your template should be using the_content(), not $post or $post->post_content. Make sure you read the documentation on theme development: developer.wordpress.org/themes/basics/template-tags Commented Oct 2, 2019 at 10:58

1 Answer 1


Try specifying the params defaults , like this:

evd_dreambig_shortcode($attr = [], $content = null){
    return $content

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.