wordpress short code

If you are not familiar with Shortcode plugin, the shortcode is WordPress-specific code that allows you to create things with codes. That way you don’t need to fill your pages and posts with long and ugly codes, they are condensed into just one line of code – [shortcode].

wordpress short code

In short, the shortcode is basically a shortcut to a big script or code. While WordPress has its own shortcodes that you can use in your posts and pages, there are several other shortcode plugin available that offer much more flexibility.

Shortcodes can be inserted manually into your blog’s theme or via the plugin. The problem is finding one that meets your needs and what you want for your blog. Don’t be afraid, in this article, we’re going to show you 10 WordPress plugins that add functionality through shortcodes, and 10 more codes that you can add yourself to your theme.

shortcodes plugins

WordPress Plugins

shortcode

A simple plugin that adds several useful shortcodes for you to display your blog content quantitatively. Some of the codes included:

  • [postcountbr] – displays the total number of posts posted
  • [catcountbr] – displays the total number of categories that contain one or more messages
  • [tagcountbr] – displays the total number of tags that contain one or more posts from
  • [totalwords] – displays the total number of words in published posts
  • [commentCount] – displays the total number of approved comments
  • [pagecount] – displays the total number of published pages

WordPress Shortcodes

This plugin includes over 20 WordPress Shortcodes and a very 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. for your blog.

You can even combine several nested shortcodes to create elements such as a list of buttons or links.

Post Content Shortcodes

This plugin adds two shortcodes:

[post-content] – This allows you to display content from an article or page, on another article or page. You must use an argument with this shortcode to specify the article ID. You can also use arguments to display a featured image, abstract, and the title of the article/page.

[post-list] – displays a list of articles in another post. It also offers optional support for arguments that allow you to customize the list such as by order, post type/status, display images, summaries, etc. You can even pull a list of posts from another blog by adding the blog ID as an argument in the shortcode.

Shortcoder

Shortcode allows you to create custom shortcodes through the visual editor. You can also store text, HTML, JavaScript snippets that are used frequently when you find yourself writing your post. It has a TinyMCE button that you can use through the blog editor to enter shortcodes, making it easy to enter your custom codes.

Hide Broken Shortcodes

At times, you may have accidentally disabled access codes, leaving their functionality somewhat disturbed. Rather than going through each page or post to remove these “broken” shortcodes, an easier way is to just hide them. This plugin will help you do that.

Column Shortcodes

If you’re looking for an easy way to create columns in your pages and posts, this is the perfect shortcode plugin. Just choose the desired column type via the shortcode selector, and it will be added to the post editor. See the examples below:

Metaphor Shortcodes

If you are looking for responsive column shortcodes for your posts and pages, you might want to use Metaphor Shortcodes. You can set certain attributes for columns like span, start, end, and CSS classes. This plugin also comes with some other shortcodes that are handy, including:

  • Post Block – displays the title and summary of any type of post, anywhere on your blog
  • Post Slider – creates a horizontal slider of any type of post and displays it in your content
  • Price List – create various types of price lists to display your products/services

UI ShortCodes

This is another plugin for creating shortcodes that comes with its own TinyMCE and Quicktag buttons. You can easily insert shortcodes into your posts and pages both in visual mode and in the HTML editor.

It’s great for beginners who know little about code. For those of you who know a little more about code, you’ll love the Syntax Highlighting Code Editor. There is also the option to export and import the shortcodes for you to use on other sites.

Last Updated Shortcode

This is a very simple plugin that allows you to add the shortcode [lastupdated] to your posts and pages. It will display the date and/or time of the last update.

Geoportal Shortcode

This plugin adds Geoportail Map to your articles and pages with a shortcode. You can configure the map size, zoom level (latitude and longitude), size, territory, layers, and more. The map supports geotagging (which you can enable with this Geolocation plugin ), so the location of your articles will be reflected and updated.

The plugin also includes a Shortcode Builder, for custom shortcodes for your maps.

Read more: Top 10 WordPress video player plugin

WordPress Shortcodes

These are simple and fun Shortcodes that you can use on your blog – no plugins required. For each shortcode we will provide you with:

  • Description about Shorcode – along with the code that should be copied and pasted into your WordPress theme’s functions.php file.
  • The [Shortcode] – which can be used anywhere in your WordPress theme (pages/posts/widgets) to add functionality.

Some of these codes might need a little customization (eg adding your Google Adsense code), so you’ll need to know a thing or two about editing codes. Others may have optional parameters you can add, such as height and width. You can find out more by clicking on the link for each Shortcode.

Insert AdSense Ads

Insert Adsense Ads in your content, wherever you want.

Shortcode :[adsense]

Code: double click to copy

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”; /* Altere com o seu ID Adsense
*/
/* 234×60, Criado */
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

Display related posts above or below content

Shortcode :[related_posts]

Code: double click to copy

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 visitors and readers to make a donation.

Shortcode :[donate]

Code: double click to copy

function donate_shortcode( $atts, $content = null) {
global $post;extract(shortcode_atts(array(
‘account’ => ‘your-paypal-email-address’,
‘for’ => $post->post_title,
‘onHover’ => ”,
), $atts));
if(empty($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 Maps location for any of your posts.

Shortcode :[googlemap src=”google_map_url”]

Code: double click to copy

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 images and texts to your website.

Shortcode :[show_file file=”http://www.test.com/test.html”]

Code : double click to copy

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.

Shortcode :[devpress-login-form]

Code : double click to copy

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

Adds a private note that will be visible only to admins.

Shortcode :[note]Sua nota aqui[/note]

Code : double click to copy

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

Adds content to the site that only logged in visitors can view.

Shortcode :[member]Apenas para membros registrados[/member]

Code: double click to copy

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

Add youtube videos as well to other media such as audio and image.

Shortcode : youtube id=”” (utilize [ ] para abrir e fechar a TAG assim [you] [/you])

Code: double click to copy

function cwp_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’, ‘cwp_youtube’);</pre>
<pre>

Obfuscate Email Address

Use WordPress Anti-Spam to hide your email from SPAMs.

Shortcode :[email address=”you@email.com”]

Code: double click to copy

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

We hope that with these shortcodes and plugins you can add great features to your WordPress site.

 

for website maintenance service contact us.

Leave a comment

echo "";