开发者

Insert a plugin manually into wordpress page

开发者 https://www.devze.com 2023-03-08 02:43 出处:网络
I am working in worpress front page. I want to add a plugin to the page at a specific location manually but adding the c开发者_如何学Pythonode to the page myself.

I am working in worpress front page.

I want to add a plugin to the page at a specific location manually but adding the c开发者_如何学Pythonode to the page myself.

I basically want to include a plugin in a certain page on a certain location. So I'm create a div...

<div id="plugin-holder">
     **Plugin-will-appear-here-with-this-code**
</div>

Don't anyone know how this is done please?

Thanks


If you're wanting a plugin to appear somewhere, you'll be looking for "shortcode" functionality.

This is actually surprisingly easy to code, check out the examples in the Codex under Shortcode API - ie:

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

Once you've called these functions you can use [bartag] in code and it will run your function and replace the shortcode with the generated text your function returns.

If you're adding shortcode functionality to your site, it generally makes most sense to code a really simple plugin and put it in that. The reason why this works best is that, over time, it's really easy to forget and upgrade a theme by mistake (or even change to a new theme) and thus break your site by losing your custom code in your former functions.php. Surprisingly, this is pretty easy to achieve and only requires some specially formatted comments at the top of your plugin file and a little common sense in coding - there are many tutorials and "how to"s around!

Here's a useful shortcode tutorial: http://www.reallyeffective.co.uk/archives/2009/06/22/how-to-code-your-own-wordpress-shortcode-plugin-tutorial-part-1/


You should add the relevant plugin code to functions.php.

I suspect you'll want to use some conditional tags, like is_home() to pinpoint your location. But maybe not, depending on what you are trying to do,

Also, if you're trying to to insert from a pre-existing plug-in, make sure you remove the register_activation_hook or activate_pluginname action.


If your plugin supports a sidebar widget you can simply "widgitize" the div tag that you wish to insert the plugin into.. Google the term and you are gonna find many resources.

0

精彩评论

暂无评论...
验证码 换一张
取 消