手动将插件插入wordpress页面

Sat*_*000 4 wordpress wordpress-theming wordpress-plugin

我在worpress头版工作.

我想手动在特定位置向页面添加插件,但我自己将代码添加到页面中.

我基本上想要在特定位置的某个页面中包含一个插件.所以我创建了一个div ...

<div id="plugin-holder">
     **Plugin-will-appear-here-with-this-code**
</div>
Run Code Online (Sandbox Code Playgroud)

请问有谁知道怎么做?

谢谢

Bri*_*n C 6

如果你想要一个插件出现在某个地方,你将会寻找"短代码"功能.

这实际上非常容易编码,在Shortcode API下查看Codex中的示例- 即:

function bartag_func( $atts ) {
    // ... do more things here ...
return "text to replace shortcode";
}
add_shortcode( 'bartag', 'bartag_func' );
Run Code Online (Sandbox Code Playgroud)

一旦你调用了这些函数,就可以在代码中使用[bartag],它将运行你的函数并用函数返回的生成文本替换短代码.

这是一个有用的短代码教程:http://www.reallyeffective.co.uk/archives/2009/06/22/how-to-code-your-own-wordpress-shortcode-plugin-tutorial-part-1/


two*_*ash 1

您应该将相关插件代码添加到functions.php.

我怀疑您会想要使用一些条件标签,例如is_home()精确定位您的位置。但也许不是,这取决于你想做什么,

另外,如果您尝试从预先存在的插件中插入,请确保删除register_activation_hookactivate_pluginname操作。