WordPress shortcodes and plugins are a great way to improve the functionality and add more elements to your website. If you have been working with WordPress for quite some time, you'd probably be using a lot of shortcodes and plugins to perform various tasks. Shortcodes are basically WordPress-specific code written to help you to do various creative things without having to mess around with the code of the core software. To put it in a non-technical user's terms, shortcodes are shortcuts to a long script or length piece of code.
Though WordPress comes with an assortment of shortcodes that can be used within your website pages and posts, there are a whole lot more shortcodes offered by WordPress, with immense flexibility. Shortcodes can be integrated into your website with the help of a plugin or you can do it manually. However, the bigger problem is to find the right shortcode and plugin that suit your website needs and demands.
Today, in this article, we are going to share a list of some useful WordPress shortcodes and plugins to jazz up your website without the risk of having to re-do everything when you plan on using a different theme.
WordPress Shortcodes:
1. Post Content Shortcodes
Post Content Shortcodes is a plugin that allows you to add two shortcodes i.e. Post list and Post content.
[post-list]
This shortcode showcases a list of posts nested in another post. The shortcode also allows you to add additional arguments including excerpts, display images, post types/statuses to use, order options and more.
[post-content]
It allows you to showcase the content of a single page or post inside another page or post. The shortcode needs an argument to specify the post ID. Other arguments such as post title, post excerpt and a featured image can also be used.
2. Shortcode
Shortcode is a simple yet powerful plugin that offers a variety of shortcodes to improve your site's functionality. Some of the codes included in this plugin:
[postcountbr] – Displays the count of the published blog posts
[catcountbr] – Displays a count of categories that includes one or more than one post
[tagcountbr] – Displays the count of tags that includes one or more posts
[totalwords] – Displays the count of words in published blog posts
[commentcount] – Displays the count of approved comments
[pagecount] – Displays the count of the published pages
3. Column Shortcodes
Column Shortcodes, as the name suggests, allow you to create columns inside your pages and posts. The plugin comes with a shortcode selector pop-up that lets you choose the column width you need. Once you have selected the column width, it will automatically be integrated into the post editor. Column Shortcodes come with 10 column widths ranging from full width to one-sixth width.
4. Insert AdSense Ads
This shortcode does not come with any plugin and can be easily added to your blog. It allows you to display AdSense ads within your posts and pages.
Shortcode: [adsense]
Code:
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-xxxxxxxxxxxxxx";
/* 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');
extract(shortcode_atts(array(
'format' => '1',
), $atts));
switch ($format) {
case 1 :
$ad = '<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxx";
/* 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');
5. Show Related Posts
Show Related Posts, as the name suggests, allow you to display related posts above or below the 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');
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');
WordPress Plugins:
1. Members
WordPress Members plugin gives you complete control over your blog by offering an intuitive and user-friendly user interface for WordPress's robust cap and role system. The plugin is a content, role, and user management plugin that was introduced to improve the functionality of this content management system. Moreover, the plugin is a components-based system and thus, it allows you to use only those features you want.
Additional features included:
Additional features included:
- Comes with a users widget and login form widget
- Allows you to give content permissions
- Integrated with clone roles
- Has explicitly deny capabilities
2. Related Posts by Zemanta
Related Posts is the most loved feature in WordPress that allows webmasters to show related posts above or below the content to hold the interest of the visitors. Related Posts by Zemanta is a great plugin for suggesting related posts from the archives at the end of a post.
Additional features included:
- Comes integrated with in-text links which are similar to related posts
- Allows your readers to explore other related content by automatically linking to other published posts
- 100% fully responsive and customizable
3. Ecwid Shopping Cart
Ecwid Shopping Cart is easy to use, secure and powerful online store solution that allows you to add a full-fledged shopping cart to your WordPress powered website.
Additional features included:
- Offers immense functionality
- Has 40+ payment options and secure HTTPS checkout
- Offers support for 45 languages
- Comes with a free e-commerce support
About Author: Anna Lewis is a professional WordPress Developer and currently working with Wordsuccor Ltd., One of the best Outsource WordPress Development Company. She is a passionate writer and has actively writing useful blogs and articles about technical stuffs.
Post a Comment