Customer Translate

Sabtu, 25 Januari 2014

20 WordPress Shortcodes and Plugins You Might Want To Try

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.
You can even combine multiple nested shortcodes to create unique elements like a list of buttons or links.
WordPress Shortcodes Plugin
More: Two similar plugins are J Shortcodes and Arconix Shortcodes - which also have a collection of useful shortcodes for use, e.g. to create content and information boxes, buttons, tabs, accordion panels, toggles and more.

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.
Shortcoder WordPress Plugin
More: If you’re looking for something similar, try out Shortcode Manager, which lets you create, manage, import and export 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.
Column Shortcodes WordPress Plugin

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.
ShortCodes UI WordPress Plugin

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.
Last Updated Shortcode WordPress Plugin

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.
Geoportail Shortcode WordPress Plugin

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.
Some of these may need a little customization (i.e. adding your own Google AdSense code), so you’ll need to know a thing or two about editing codes. Others may have optional parameters that you can add, like width and height. You can find out more by clicking on the link for each shortcode.

Insert AdSense Ads

Insert AdSense ads within your content, wherever you’d like.
Shortcode: [adsense]
Code:
  1. function adsense_shortcode( $atts ) {  
  2.         extract(shortcode_atts(array(  
  3.             'format' => '1',  
  4.         ), $atts));  
  5.           
  6.         switch ($format) {  
  7.                 case 1 :  
  8.                     $ad = '<script type="text/javascript"><!--  
  9.                         google_ad_client = "pub-6928386133078955"; 
  10.                         /* 234x60, created 16/09/08 */ 
  11.                         google_ad_slot = "0834408702"; 
  12.                         google_ad_width = 234; 
  13.                         google_ad_height = 60; 
  14.                         //--> 
  15.                         </script> 
  16.                         <script type="text/javascript" 
  17.                         src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> 
  18.                         </script>';  
  19.                 break;  
  20.         }  
  21.         return $ad;  
  22. }  
  23. add_shortcode('adsense''adsense_shortcode');  

Show Related Posts

Show related posts above or below your content.
Shortcode: [related_posts]
Code:
  1. function related_posts_shortcode( $atts ) {  
  2.         extract(shortcode_atts(array(  
  3.         'limit' => '5',  
  4.     ), $atts));  
  5.       
  6.     global $wpdb$post$table_prefix;  
  7.       
  8.     if ($post->ID) {  
  9.             $retval = '<ul>';  
  10.             // Get tags  
  11.             $tags = wp_get_post_tags($post->ID);  
  12.             $tagsarray = array();  
  13.             foreach ($tags as $tag) {  
  14.                     $tagsarray[] = $tag->term_id;  
  15.             }  
  16.             $tagslist = implode(','$tagsarray);  
  17.               
  18.             // Do the query  
  19.             $q = "SELECT p.*, count(tr.object_id) as count 
  20.                     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 
  21.                                 AND p.post_status = 'publish' 
  22.                                 AND p.post_date_gmt < NOW() 
  23.                     GROUP BY tr.object_id 
  24.                     ORDER BY count DESC, p.post_date_gmt DESC 
  25.                     LIMIT $limit;";  
  26.   
  27.             $related = $wpdb->get_results($q);  
  28.             if ( $related ) {  
  29.                     foreach($related as $r) {  
  30.                             $retval .= ' 
  31.     <li><a title="'.wptexturize($r->post_title).'" href="'.get_permalink($r->ID).'">'.wptexturize($r->post_title).'</a></li> 
  32. ';  
  33.             } else {  
  34.                     $retval .= ' 
  35.     <li>No related posts found</li> 
  36. ';  
  37.             }  
  38.             $retval .= '</ul> 
  39. ';  
  40.             return $retval;  
  41.     }  
  42.     return;  
  43. }  
  44. 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:
  1. function donate_shortcode( $atts$content = null) {  
  2.     global $post;extract(shortcode_atts(array(  
  3.         'account' => 'your-paypal-email-address',  
  4.         'for' => $post->post_title,  
  5.         'onHover' => '',  
  6.     ), $atts));  
  7.     if(emptyempty($content)) $content='Make A Donation';  
  8.             return '<a href="https://www.paypal.com/cgi-bin/webscr? 
  9. $account.'&item_name=Donation for '.$for.'" title="'.$onHover.'">'.$content.'</a>'; 
  10. } 
  11. 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:
  1. function rockable_googlemap($atts$content = null) {  
  2.    extract(shortcode_atts(array(  
  3.                "width" => '940',  
  4.                "height" => '300',  
  5.                "src" => ''  
  6.    ), $atts));  
  7.   
  8. return '<div> 
  9.             <iframe src="'.$src.'&output=embed" frameborder="0" marginwidth="0"  
  10. marginheight="0" scrolling="no" width="'.$width.'" height="'.$height.'"></iframe> 
  11.         </div> 
  12.         ';  
  13. }  
  14.   
  15. 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:
  1. function show_file_func( $atts ) {  
  2.   extract( shortcode_atts( array(  
  3.     'file' => ''  
  4.   ), $atts ) );  
  5.   
  6.   if ($file!='')  
  7.     return @file_get_contents($file);  
  8. }  
  9.   
  10. 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:
  1. function devpress_login_form_shortcode() {  
  2.     if ( is_user_logged_in() )  
  3.         return '';  
  4.   
  5.     return wp_login_form( array'echo' => true ) );  
  6. }  
  7.   
  8. function devpress_add_shortcodes() {  
  9.     add_shortcode( 'devpress-login-form''devpress_login_form_shortcode' );  
  10. }  
  11.   
  12. 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:
  1. add_shortcode( 'note''sc_note' );  
  2.   
  3. function sc_note( $atts$content = null ) {  
  4.         if ( current_user_can( 'publish_posts' ) )  
  5.                 return '<div class="note">'.$content.'</div>';  
  6.         return '';  
  7. }  

Registered Users Only Content

Add content that only registered users of your blog can see.
Shortcode: [member]For Registered Users Only[/member]
Code:
  1. add_shortcode( 'member''member_check_shortcode' );  
  2.   
  3. function member_check_shortcode( $atts$content = null ) {  
  4.         if ( is_user_logged_in() && !is_null$content ) && !is_feed() )  
  5.                 return $content;  
  6.         return '';  
  7. }  

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:
  1. function wptuts_youtube($atts$content=null){    
  2.   
  3.     extract(shortcode_atts( array('id' => ''), $atts));    
  4.   
  5.     $return = $content;    
  6.     if($content)  
  7.         $return .= "<br /><br />";   
  8.   
  9.      $return .= '<iframe width="560" height="349" src="http://www.youtube.com/embed/' . $id . '" frameborder="0" allowfullscreen></iframe>';   
  10.   
  11.      return $return;  
  12. }    
  13. 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:
  1. function emailbot_ssc($attr) {  
  2.     extract( shortcode_atts( array(  
  3.         'address' => '',  
  4.     ), $attr ) );  
  5.   
  6.      $email = '<a class="email_link" href="mailto:'.antispambot($attr['address']).'" title="Send Us An Email" target="_blank">';  
  7.      $email .= antispambot($attr['address']);  
  8.      $email .= '</a>';  
  9.   
  10.      return $email;  
  11. }  
  12. add_shortcode('email''emailbot_ssc'); 
Chrome Pointer