Free Premium WordPress Themes Contest  Click here

Remember Me
SEND

Top 10 WordPress Shortcodes

We deliver the most useful Top 10 WordPress Shortcodes to insert in themes quietly, not raising a clamour. Keep it in secret: shortcodes listed allow to elaborately introduce data into a post without brutal coding. Practise your own coding, even though it is in short. And do not fake it, that is not yoga!

Google Docs Viewer Shortcode

Google Docs Viewer Shortcode

Plugin allows to add a link to a Google Docs Viewer by entering the link to the PDF in the shortcode’s single parameter:

function pdflink($attr, $content) {  
    if ($attr['href']) {  
        return '<a class="pdf" href="http://docs.google.com/viewer?url=' . $attr['href'] . '">'.$content.'</a>';  
    } else {  
        $src = str_replace("=", "", $attr[0]);  
        return '<a class="pdf" href="http://docs.google.com/viewer?url=' . $src . '">'.$content.'</a>';  
    }  
}  
add_shortcode('pdf', 'pdflink');

Usage:

[pdf=http://manuals.info.apple.com/en_US/Enterprise_Deployment_Guide.pdf]Link text.[/pdf]  

Displaying Related Posts Shortcode

Displaying Related Posts Shortcode

The perfect way to keep website visitors longer is related posts. Use a simple shortcode to replace specific plugins:

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');

Usage:

[related_posts]

Google AdSense Shortcode

Google AdSense Shortcode

Shortcode allows to insert a parameter-less shortcode into a post to add an ad:

function showads() {  
    return '<script type="text/javascript"><!-- 
google_ad_client = "<em>your client id</em>"; 
google_ad_slot = "<em>your ad slot id</em>"; 
google_ad_width = <em>width</em>; 
google_ad_height = <em>height</em>; 
//--> 
</script> 
<script type="text/javascript" 
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> 
</script> 
';  
}  
  
add_shortcode('adsense', 'showads');

Usage:

[adsense]

Google Chart Shortcode

Google Chart Shortcode

Shortcode dedicated for you to create dynamic charts online:

function chart_shortcode( $atts ) {
	extract(shortcode_atts(array(
	    'data' => '',
	    'colors' => '',
	    'size' => '400x200',
	    'bg' => 'ffffff',
	    'title' => '',
	    'labels' => '',
	    'advanced' => '',
	    'type' => 'pie'
	), $atts));

	switch ($type) {
		case 'line' :
			$charttype = 'lc'; break;
		case 'xyline' :
			$charttype = 'lxy'; break;
		case 'sparkline' :
			$charttype = 'ls'; break;
		case 'meter' :
			$charttype = 'gom'; break;
		case 'scatter' :
			$charttype = 's'; break;
		case 'venn' :
			$charttype = 'v'; break;
		case 'pie' :
			$charttype = 'p3'; break;
		case 'pie2d' :
			$charttype = 'p'; break;
		default :
			$charttype = $type;
		break;
	}

	if ($title) $string .= '&chtt='.$title.'';
	if ($labels) $string .= '&chl='.$labels.'';
	if ($colors) $string .= '&chco='.$colors.'';
	$string .= '&chs='.$size.'';
	$string .= '&chd=t:'.$data.'';
	$string .= '&chf='.$bg.'';

	return '<img title="'.$title.'" src="http://chart.apis.google.com/chart?cht='.$charttype.''.$string.$advanced.'" alt="'.$title.'" />';
}
add_shortcode('chart', 'chart_shortcode');

Usage:

[chart data="41.52,37.79,20.67,0.03" bg="F7F9FA" labels="Reffering+sites|Search+Engines|Direct+traffic|Other" colors="058DC7,50B432,ED561B,EDEF00" size="488x200" title="Traffic Sources" type="pie"]

Download: http://wordpress.org/extend/plugins/google-chart-shortcode/

TweetMeme Button Shortcode

TweetMeme Button Shortcode

TweetMeme Button Shortcode shortcode allows to display “Retweet” button on your blog posts:

function tweetmeme(){
	return '<div class="tweetmeme"><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></div>';
}
add_shortcode('tweet', 'tweetmeme');

Usage:

[tweet]

Download: http://wordpress.org/extend/plugins/tweetmeme/

WordPress Blog URL and Page URL Shortcode

Shortcode allows to receive the WordPress URL:

function bloginfo_shortcode( $atts ) {
	extract(shortcode_atts(array(
		'key' => '',
	), $atts));
	return get_bloginfo($key);
}
add_shortcode('bloginfo', 'bloginfo_shortcode');

Usage:

[bloginfo key="template_url"]

Download: http://wordpress.org/extend/plugins/blog-url-and-page-url-shortcode/

Private Content Shortcode

Private Content Shortcode

Shortcode allows to create private content available for registered users only:

function cwc_member_check_shortcode( $atts, $content = null ) {
	 if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
		return $content;
	return '';
}

add_shortcode( 'member', 'cwc_member_check_shortcode' );

Usage:

[member]This text will be only displayed to registered users.[/member]

Download: http://wordpress.org/extend/plugins/shortcodes-ultimate/changelog/

Google Map Shortcode

Google Map Shortcode

Shortcode provide full integration of Google Map instances into website, allowing to display multiple maps on web pages:

function fn_googleMaps($atts, $content = null) {  
   extract(shortcode_atts(array(  
      "width" => '640',  
      "height" => '480',  
      "src" => ''  
   ), $atts));  
   return '<iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'"></iframe>';  
}  
add_shortcode("googlemap", "fn_googleMaps");

Usage:

[googlemap width="600" height"360" src="http://google.com/maps/?ie=..."] 

Download: http://wordpress.org/extend/plugins/google-map-shortcode/

YouTube Shortcode

YouTube Shortcode

This shortcode allows to embed YouTube videos anywhere on website using WordPress shortcode. Paste the code into your functions.php file:

unction cwc_youtube($atts) {
	extract(shortcode_atts(array(
		"value" => 'http://',
		"width" => '475',
		"height" => '350',
		"name"=> 'movie',
		"allowFullScreen" => 'true',
		"allowScriptAccess"=>'always',
	), $atts));
	return '<object style="height: '.$height.'px; width: '.$width.'px"><param name="'.$name.'" value="'.$value.'"><param name="allowFullScreen" value="'.$allowFullScreen.'"></param><param name="allowScriptAccess" value="'.$allowScriptAccess.'"></param><embed src="'.$value.'" type="application/x-shockwave-flash" allowfullscreen="'.$allowFullScreen.'" allowScriptAccess="'.$allowScriptAccess.'" width="'.$width.'" height="'.$height.'"></embed></object>';
}
add_shortcode("youtube", "cwc_youtube");

Usage:

[youtube value="http://www.youtube.com/watch?v=1aBSPn2P9bg"]

Download: http://wordpress.org/extend/plugins/youtube-shortcode/

RSS Feed Shortcode

RSS Feed Shortcode

This shortcode allows to embed any RSS feed on website. Paste the code below into your functions.php file:

include_once(ABSPATH.WPINC.'/rss.php');

function cwc_readRss($atts) {
    extract(shortcode_atts(array(
	"feed" => 'http://',
      "num" => '1',
    ), $atts));

    return wp_rss($feed, $num);
}

add_shortcode('rss', 'cwc_readRss');

Usage:

[rss feed="http://feeds.feedburner.com/catswhocode" num="5"]

Download: http://wordpress.org/extend/plugins/rss-shortcode/screenshots/

Subscribe to Our Newsletter
Success! You`ve been signed up. Please check your e-mail for our confirmation message.
"" is already subscribed to list Divine Project Newsletters
Invalid email
JOIN!
* Your e-mail address will only be used for our newsletter.
Get your social on
Subscribe to Divine Elemente
Post comment as twitter logo facebook logo
Sort: Newest | Oldest
SHOPPING CART
Product Quantity Total
Your Basket Is Empty
CONTINUE
Your Prepay Account
Current Balance: $
Enter a deposit amount in the field above and make it now. And the use of prepaid deposits will save your time and give you a $2-discount purchasing any item at our website next time. More details on Prepay use.
DEPOSIT NOW
CANCEL
Loading
"" is already subscribed to Divine Project Newsletter.
Invalid email
Success! You`ve been signed up. Please check your e-mail for our confirmation letter.
FREE UPDATES Enter your E-mail: JOIN US Privacy
8835 subscribers Divine Project RSS

Adobe®, Photoshop®, Fireworks®, Illustrator®, Flash® are registered trademarks of Adobe Systems Incorporated.


How to make WordPress theme from PSD template | How to Create Basic PSD template | How to Upload WordPress Theme to Internet | How to Change WordPress Themes | Sell / Buy WordPress Themes

© 2012 Divine Elemente. All Rights Reserved. Design by Ivan Sulimenko