Adding a shortcode
-
Great plugin but I only wanted to use it very selectively on certain posts and pages. So rather than edit the template files in my theme, I added some code to my theme functions.php which allows the use of [likethis] as a shortcode:
function register_shortcodes() { add_shortcode("likethis", "likethis_shortcode"); } function likethis_shortcode() { if(function_exists('printLikes')){ ob_start(); printLikes(get_the_ID()); return ob_get_clean(); } } add_action( 'init', 'register_shortcodes');
Hope that proves useful to someone – and would love to see it in the plugin itself.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Adding a shortcode’ is closed to new replies.