Using Shortcodes for Plug-ins in WordPress
by WeblashAdmin on Sep.05, 2009, under Uncategorized, WordPress, development, plug-ins
First step: read the shortcode API reference in WordPress Codex. I had a difficult time figuring out exactly where to place the “add_shortcode” function call.
Second step: Place the “add_shortcode(‘shortcut name’, ‘shortcut function’);” to the same place you put your add_action and add_filter calls — I’m basing this off the excellent tutorial I found — “How to Write a WordPress Plug-in“:
//add actions
add_action('admin_menu', 'DevloungePluginSeries_ap');
add_action('wp_head', array(&$dl_pluginSeries, 'addHeaderCode'), 1);
add_action('activate_devlounge-plugin-series/devlounge-plugin-series.php', array(&$dl_pluginSeries, 'init'));
//Filters
add_filter('the_content', array(&$dl_pluginSeries, 'addContent'),1);
add_filter('get_comment_author', array(&$dl_pluginSeries, 'authorUpperCase'));
//Shortcodes
add_shortcode('shortcodename', array(&$dl_pluginSeries, 'function'));














October 20th, 2011 on 6:56pm
I am not sure why the shortcode function is sometimes an array, but is supposed to be a string parameter.
I think it has something to do with the syntax for invoking a function by name within a class though, but I’ve seen instances of array(“string”, “string”) being used for this argument.
Trying to unwind that…