我将以下代码放在WP“init”回调中(或加载插件时)。
add_shortcode(\'my_shortcode\',
function($atts, $content =\'\') { die(); }
);
if (!shortcode_exists(\'my_shortcode\')) die();
在我的页面中,我放入“[my_shortcode]“”当我查看页面时,我得到“****”
知道我的代码怎么了吗?
更新:我简化了问题。
我在主题索引中添加了短代码定义。php文件。
<?php
/**
* 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: http://codex.wordpress.org/Template_Hierarchy
*
* @package GeneratePress
*/
if ( ! defined( \'ABSPATH\' ) ) {
exit; // Exit if accessed directly.
}
add_shortcode(\'myt_active_plugins\',
function($atts, $content, $name) {
return \'Shortcode injected\';
}
);
我停用了所有插件。I(重新)安装WP3.5.2
我创建了一个帖子:
Welcome *[myt_active_plugins]*
我发表了这篇文章,当我看到它时,我得到了:Welcome **
作为最后的检查,我安装了一个shortcode插件(Shortcodes Ultimate),它的作用是一样的。