WordPress Plugins
Here are some plugins that allow you to use or custom build shortcodes for use on WordPress. Where relevant, an alternative plugin that does pretty much the same thing is suggested after each plugin.1. Shortcode
A simple plugin that adds several useful shortcodes for you to show off your blog’s contents quantitatively. A few of the codes include:[postcountbr]
– displays total number of published blog posts[catcountbr]
– displays total number of categories that contain one or more posts[tagcountbr]
– displays total number of tags that contain one or more posts[totalwords]
– displays total number of words in published posts[commentcount]
– displays the total number of approved comments[pagecount]
– displays the total number of published pages
2. WordPress Shortcodes
This plugin includes more than 20 WordPress shortcodes and an easy-to-use shortcode editor. You can use it to add cool elements like:- SEO-ready tabs, buttons
- author cards
- message boxes
- smart links
- sections
- lists, etc to your blog.
3. Post Content Shortcodes
This plugin adds two shortcodes:[post-content]
– lets you display the content of a single post or page, within another post or page.
You must use an argument within the shortcode to specify the post ID.
You can also use arguments to display a featured image, post excerpt,
and post title.[post-list]
– displays a list of posts within another post.
It also supports optional arguments for customizing the list such as
order options, post types/statuses to use, display images, excerpts,
etc. You can even pull a list of posts from another blog, by adding the
blog’s ID as an argument in the shortcode.More: If want to display a list of attachments within a post, check out the List Attachments Shortcode plugin (by the same developer).
4. Shortcoder
Shortcoder lets you create custom shortcodes via a visual editor. You can also store frequently used text, HTML, and JavaScript snippets. It has a tinyMCE button that you can use from the blog editor to insert shortcodes, thereby allowing you to add your own custom shortcodes.5. Hide Broken Shortcodes
Sometimes, you may have accidentally disabled shortcodes, leaving their functionality somewhat disrupted. Rather than go through each page or post to remove these "broken" shortcodes, an easier way is just to hide them. This plugin will help you do that.More: Hide Unwanted Shortcodes is a similar plugin that works to prevent broken shortcodes from showing up on the site. You can then edit the shortcode from the plugin’s settings page.
6. Column Shortcodes
If you’re looking for an easy way to create columns within your posts and pages, this is the perfect shortcode plugin. Just choose your desired column width from the shortcode selector pop up, and it will be added to the post editor. There are 10 column widths to choose from full width down to one sixth. You can also customize the padding of each individual column.7. Metaphor Shortcodes
If you’re looking for a responsive column grid for your posts and pages, try out the Metaphor Shortcodes plugin. You can set certain attributes for your columns such as span, start, end, and class. This plugin also comes with a few other handy shortcodes, including:- Post Block Shortcode – display the title and excerpt of any post type, anywhere on your blog
- Post Slider Shortcode – create a horizontal slider of any post type and display within your content
- Pricing Table Shortcode – create various types of pricing tables to display within your content
8. ShortCodes UI
ShortCodes UI is another plugin for creating shortcodes that come with its own tinyMCE and Quicktag buttons. You can easily insert shortcodes in your posts and pages from both the visual and HTML editors.It is great for beginners who know little about code, and there are video tutorials to help. For those who know a little more about code, they would probably appreciate the syntax highlighting code editor. There is also an import/export feature so you can move your shortcodes from one site to another and even share with friends.
More: My Shortcodes is a similar plugin with a beautiful UI that lets you create custom shortcodes. Within the plugin’s admin panel, you can manage, edit, activate/deactivate, and export elements and shortcodes. The live preview lets you see how your shortcode looks without adding it to a post or page.
9. Last Updated Shortcode
This is a very simple plugin that lets you add the[lastupdated]
shortcode
to your posts and pages. It will then display the date and/or time of
the last update. There are also options to change how the date/time is
formatted.10. Geoportail Shortcode
This one adds a Geoportail map into your posts and pages with a shortcode. You can then set the map size, zoom level, location (latitude and longitude), size (normal, mini), territory, layers and more. The map supports geotagging (which you can enable with this plugin Geolocation), so the location of your posts will be reflected.The plugin also includes a shortcode builder, for custom map shortcodes, and a live preview, so that you can see your map before posting it.
Shortcodes
These are fun and simple shortcodes that you can use on your blog – no plugin necessary. For each shortcode we will provide you with:- The meat of the shortcode – a long piece of code that must be pasted into the Theme functions file (functions.php) for your blog, from the Editor in the WordPress dashboard (Appearance > Editor).
- The shortcode, which can be placed anywhere within your posts and pages, to add the functionality.
Insert AdSense Ads
Insert AdSense ads within your content, wherever you’d like.Shortcode:
[adsense]
Code:
- function adsense_shortcode( $atts ) {
- extract(shortcode_atts(array(
- 'format' => '1',
- ), $atts));
- switch ($format) {
- case 1 :
- $ad = '<script type="text/javascript"><!--
- google_ad_client = "pub-6928386133078955";
- /* 234x60, created 16/09/08 */
- google_ad_slot = "0834408702";
- google_ad_width = 234;
- google_ad_height = 60;
- //-->
- </script>
- <script type="text/javascript"
- src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
- </script>';
- break;
- }
- return $ad;
- }
- add_shortcode('adsense', 'adsense_shortcode');
Show Related Posts
Show related posts above or below your content.Shortcode:
[related_posts]
Code:
- function related_posts_shortcode( $atts ) {
- extract(shortcode_atts(array(
- 'limit' => '5',
- ), $atts));
- global $wpdb, $post, $table_prefix;
- if ($post->ID) {
- $retval = '<ul>';
- // Get tags
- $tags = wp_get_post_tags($post->ID);
- $tagsarray = array();
- foreach ($tags as $tag) {
- $tagsarray[] = $tag->term_id;
- }
- $tagslist = implode(',', $tagsarray);
- // Do the query
- $q = "SELECT p.*, count(tr.object_id) as count
- FROM $wpdb->term_taxonomy AS tt, $wpdb->term_relationships AS tr, $wpdb->posts AS p WHERE tt.taxonomy ='post_tag' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tr.object_id = p.ID AND tt.term_id IN ($tagslist) AND p.ID != $post->ID
- AND p.post_status = 'publish'
- AND p.post_date_gmt < NOW()
- GROUP BY tr.object_id
- ORDER BY count DESC, p.post_date_gmt DESC
- LIMIT $limit;";
- $related = $wpdb->get_results($q);
- if ( $related ) {
- foreach($related as $r) {
- $retval .= '
- <li><a title="'.wptexturize($r->post_title).'" href="'.get_permalink($r->ID).'">'.wptexturize($r->post_title).'</a></li>
- ';
- } else {
- $retval .= '
- <li>No related posts found</li>
- ';
- }
- $retval .= '</ul>
- ';
- return $retval;
- }
- return;
- }
- add_shortcode('related_posts', 'related_posts_shortcode');
Insert PayPal Donation Link
Add a PayPal button, making it easy for readers and visitors to donate.Shortcode:
[donate]
Code:
- function donate_shortcode( $atts, $content = null) {
- global $post;extract(shortcode_atts(array(
- 'account' => 'your-paypal-email-address',
- 'for' => $post->post_title,
- 'onHover' => '',
- ), $atts));
- if(emptyempty($content)) $content='Make A Donation';
- return '<a href="https://www.paypal.com/cgi-bin/webscr?
- $account.'&item_name=Donation for '.$for.'" title="'.$onHover.'">'.$content.'</a>';
- }
- add_shortcode('donate', 'donate_shortcode');
Display A Google Map
Add a Google Map of any location to your posts.Shortcode:
[googlemap src="google_map_url"]
Code:
- function rockable_googlemap($atts, $content = null) {
- extract(shortcode_atts(array(
- "width" => '940',
- "height" => '300',
- "src" => ''
- ), $atts));
- return '<div>
- <iframe src="'.$src.'&output=embed" frameborder="0" marginwidth="0"
- marginheight="0" scrolling="no" width="'.$width.'" height="'.$height.'"></iframe>
- </div>
- ';
- }
- add_shortcode("googlemap", "rockable_googlemap");
Display External Files
Add external files like text and images into your posts.Shortcode:
[show_file file="http://www.test.com/test.html"]
Code:
- function show_file_func( $atts ) {
- extract( shortcode_atts( array(
- 'file' => ''
- ), $atts ) );
- if ($file!='')
- return @file_get_contents($file);
- }
- add_shortcode( 'show_file', 'show_file_func' );
Add A Login Form
Add a login form to your posts and pages, not just the sidebar.Shortcode:
[devpress-login-form]
Code:
- function devpress_login_form_shortcode() {
- if ( is_user_logged_in() )
- return '';
- return wp_login_form( array( 'echo' => true ) );
- }
- function devpress_add_shortcodes() {
- add_shortcode( 'devpress-login-form', 'devpress_login_form_shortcode' );
- }
- add_action( 'init', 'devpress_add_shortcodes' );
Display Private Notes
Add a private note to your post or page that will only be visible to admins.Shortcode:
[note]Your Note Here[/note]
Code:
- add_shortcode( 'note', 'sc_note' );
- function sc_note( $atts, $content = null ) {
- if ( current_user_can( 'publish_posts' ) )
- return '<div class="note">'.$content.'</div>';
- return '';
- }
Registered Users Only Content
Add content that only registered users of your blog can see.Shortcode:
[member]For Registered Users Only[/member]
Code:
- add_shortcode( 'member', 'member_check_shortcode' );
- function member_check_shortcode( $atts, $content = null ) {
- if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
- return $content;
- return '';
- }
Embed YouTube Videos
Not only can this embed YouTube videos, but it can also be used for other media like audio and images.Shortcode:
[youtube id="_ggWarwhv9M"]Check out this video![/youtube]
Code:
- function wptuts_youtube($atts, $content=null){
- extract(shortcode_atts( array('id' => ''), $atts));
- $return = $content;
- if($content)
- $return .= "<br /><br />";
- $return .= '<iframe width="560" height="349" src="http://www.youtube.com/embed/' . $id . '" frameborder="0" allowfullscreen></iframe>';
- return $return;
- }
- add_shortcode('youtube', 'wptuts_youtube');
Obfuscate Email Address
Keep your email safe from spammers by rendering it unclear when scraped from a page.Shortcode:
[email address="you@email.com"]
Code:
- function emailbot_ssc($attr) {
- extract( shortcode_atts( array(
- 'address' => '',
- ), $attr ) );
- $email = '<a class="email_link" href="mailto:'.antispambot($attr['address']).'" title="Send Us An Email" target="_blank">';
- $email .= antispambot($attr['address']);
- $email .= '</a>';
- return $email;
- }
- add_shortcode('email', 'emailbot_ssc');