Shortcode not being executed


I place the following code within the WP ‘init’ callback (or when plugins are loaded).

               function($atts, $content ='') { die(); }
if (!shortcode_exists('my_shortcode')) die();

In my page I put “[my_shortcode]

When I view the page I get “****”

Any idea what happened to my code?

I have simplified the problem.

I added the shortcode definition in my theme’s index.php file.

 * The main template file.
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more:
 * @package GeneratePress

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.

             function($atts, $content, $name) {
                    return 'Shortcode injected';

I deactivated all plugins.

I (re)installed WP3.5.2

I created a post:

Welcome *[myt_active_plugins]*

I published the post and when I viewed it I got:

Welcome **

As a final check I installed a shortcode plugin, (Shortcodes Ultimate) and it acted the same.

Karl Bochert 2 years 2020-01-04T08:38:50-05:00 0 Answers 57 views 0

Leave an answer