Saturday 17 May 2014

Wordpress Plugin: How to add plugin short code into Wordpress page

<?php echo do_shortcode('[gallery]'); ?>

All the options for the shortcode are at http://wordpress.org/extend/plugins/rotatingtweets/installation/

You wouldn't normally put something like
<?php echo do_shortcode('[gallery]'); ?>
in a functions.php file since it immediately displays the information in question - but you might consider putting it straight into another template file (like footer.php or page.php for example).

Normally though, if you wanted to put rotating tweets into a particular area of your template and it wasn't in a post (where you would use a shortcode) or in a widget area (where you would use a widget), I'd be tempted to add an extra widget area to your template. You can do this by adding some code to the template and by adding a register_sidebar command to functions.php using similar code to that outlined here.

Shortcode in a Widget. Widgets don't actually process shortcodes, but its easy to make them do so, have a look here:
tldr; add this to your functions.php file :)
add_filter('widget_text', 'do_shortcode');

No comments:

Post a Comment