Showing posts with label Posts. Show all posts
Showing posts with label Posts. Show all posts

Tuesday, 31 December 2013

Amazing Post Navigation For Blogger


It's already 2014 here in India, so I'd like to wish you all a very happy New Year. Stay safe and don't drink to much ;)

It's still New Year's Eve in most of part of the globe, so let me end the year with a final post on this blog. And this tutorial comes from the Blogger King MBT.

It's a new stylish jQuery post navigation for your blog. It'll appear on in your Blogger posts and it'll definitely catch the attention of your readers. The pagination buttons make no sense when placed at the bottom of comments container.

Add This To Blogger:

First. we will add CSS and some necessary script to our Blogger template.

  • Go To Blogger > Template
  • Click "Edit HTML"
  • Search and add following CSS just above ]]></b:skin>

    /*################MBT Pager ##########################*/

    .mbt-pager { border-top: 2px dashed #ddd; border-bottom: 2px dashed #ddd;  margin-bottom: 10px;   overflow:hidden; padding:0px;}
    .mbt-pager li.next { float: right; padding:0px; background:none; margin:0px;}
    .mbt-pager li.next a { padding-left: 24px; }

    .mbt-pager li.previous { margin:0px -2px 0px 0px; float: left;  border-right:1px solid #ddd; padding:0px; background:none;
    }
    .mbt-pager li.previous a { padding-right: 24px;  }

    .mbt-pager li.next:hover, .mbt-pager li.previous:hover  {background:#333333; }

    .mbt-pager li { width: 50%; display: inline; float: left; text-align: center; }
    .mbt-pager li a { position: relative; min-height: 77px; display: block; padding: 15px 46px 15px; outline:none; text-decoration:none;}

    .mbt-pager li i { color: #ccc; font-size: 18px; }

    .mbt-pager li a strong { display: block; font-size: 20px; color: #ccc; letter-spacing: 0.5px; font-weight: bold; text-transform: uppercase; font-family:oswald, sans-serif, arial; margin-bottom:10px;}

    .mbt-pager li a span { font-size: 15px; color: #666;  font-family:oswald,Helvetica, arial; margin:0px;}
    .mbt-pager li a:hover span,
    .mbt-pager li a:hover i { color: #ffffff; }
    .mbt-pager li.previous i { float:left; margin-top:15%; margin-left:5%; }
    .mbt-pager li.next i { float: right;
    margin-top: 15%;
    margin-right: 5%; }

    .mbt-pager li.next i, .mbt-pager li.previous i ,
    .mbt-pager li.next,  .mbt-pager li.previous{
    -webkit-transition-property: background color; -webkit-transition-duration: 0.4s; -webkit-transition-timing-function: ease-out;
    -moz-transition-property: background color; -moz-transition-duration: 0.4s; -moz-transition-timing-function: ease-out;
    -o-transition-property: background color; -o-transition-duration: 0.4s; -o-transition-timing-function: ease-out;
    transition-property: background color; transition-duration: 0.4s; transition-timing-function: ease-out; }

    .fa-chevron-right {padding-right:0px;}

  • Now, we will add fonts from Google Fonts & jQuery support.  Search for <head> and just below it paste the following code:

<script src="http://widcraft.googlecode.com/svn/jquery.js" type="text/javascript"></script>
<link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'/>

  • Now, it's for the main event. We will add our navigator to the bottom of your post. Search for data:post.body and paste following below it:

    <b:if cond='data:blog.pageType == &quot;item&quot;'>

    <b:if cond='data:blog.pageType != &quot;static_page&quot;'>

    <ul class='mbt-pager'>

            <li class='next'>
    <b:if cond='data:newerPageUrl'>
    <i class='fa fa-chevron-right'/><a class='newer-link' expr:href='data:newerPageUrl' expr:id='data:widget.instanceId + &quot;_blog-pager-newer-link&quot;' rel='next'/>
    <b:else/>
    <i class='fa fa-chevron-right'/><a rel='next'><strong>Next</strong> <span>You are viewing Most Recent Post</span></a>
    </b:if>
    </li>

        <li class='previous'>
    <b:if cond='data:olderPageUrl'>
    <i class='fa fa-chevron-left'/><a class='older-link' expr:href='data:olderPageUrl' expr:id='data:widget.instanceId + &quot;_blog-pager-older-link&quot;' rel='previous'/>
    <b:else/>
    <i class='fa fa-chevron-left'/><a rel='previous'><strong>Previous</strong> <span>You are viewing Last Post</span></a>
    </b:if>
    </li>

        </ul>


    <script type='text/javascript'>
    //<![CDATA[
    (function($){  
        var newerLink = $('a.newer-link');
        var olderLink = $('a.older-link');
        $.get(newerLink.attr('href'), function (data) {
         newerLink.html('<strong>Next</strong> <span>'+$(data).find('.post h3.post-title').text()+'</span>');  
        },"html");
        $.get(olderLink.attr('href'), function (data2) {
         olderLink.html('<strong>Previous</strong> <span>'+$(data2).find('.post h3.post-title').text()+'</span>');  
        },"html");
    })(jQuery);
    //]]>
    </script>

          </b:if></b:if>

Save your template, and that's it for this year!

Huge Announcement:

In 2014, BWidgets.com will only cover stuff related to Blogger & Google. All WordPress and other stuff will go into your NEW WEBSITE (details coming soon). Our new site will also feature a new Google PageRank checker among other cool tools. So stay tuned!

Sunday, 17 November 2013

Using A Different Post Template For Posts Within A Specific Category

On Thursday I posted an article about using different post template for posts formats, but now it's time for doing the same thing with categories, instead of formats. You can use this trick in your WordPress to create different type of posts, such as portfolio items.

We discussed everything previously, so let's get into this trick:

Using A Different Post Template:

In this tutorial, we'll create a different post template for the cat-1 category. We'll use multiple single.php files to make it more easy and customizable.

Create a single.php file for your category. We're going to name it single-cat-1.php. You can also copy your single.php file to this template and make some changes that you want in the video template.

Upload single-cat-1.php to the root of your current theme. Same place where single.php file is located.

Okay, so now we'll tell WordPress to use single-cat-1.php template for the posts within video category. Add following to your theme's functions.php file:

add_action('template_include', 'load_single_template');
  function load_single_template($template) {
    $new_template = '';

    // single post template
    if( is_single() ) {
      global $post;

      // 'cat-1' is category slugs
      if( has_term('cat-1', 'category', $post) ) {
        // use template file single-template-cat-1.php
        $new_template = locate_template(array('single-cat-1.php' ));
      }

    }
    return ('' != $new_template) ? $new_template : $template;
  }

In above code, replace cat-1 is the slug of your category, and single-cat-1.php is your custom post template file. Save the file. That's it.

Thursday, 14 November 2013

Using A Different Post Template For Posts Formats In WordPress

Post Formats is a theme feature which was introduced with the WordPress 3.1 release. It gave us a new feature to style posts based on its format. If you ever used WordPress' default themes, then you might know about their different post templates based on the post format. So it's time for you to style your posts based on its format. Here's a demo of this trick from my own WordPress site:

This is a simple post.

This is a video post with a different template.

Add Post Format Support To Your WordPress Theme:

Before starting this tutorial, it's important for you to add support for post formats in your current WordPress theme. If this section is available in your post editor then you can skip this step:


If not, then follow this tutorial.

Using A Different Post Template:

In this tutorial, we'll create a different post template for the Video format. Most of developers uses a single post template file for all different format. But we'll use multiple single.php files to make it more easy and customizable.

Create a single.php file for your post format (we're using Video). We're going to name it single-video.php. You can also copy your single.php file to this template and make some changes that you want in the video template.

Upload single-video.php to the root of your current theme. Same place where single.php file is located.

Okay, so now we'll tell WordPress to use single-video.php template for the posts with video format. Add following to your theme's functions.php file:

add_action('template_include', 'load_single_template');
  function load_single_template($template) {
    $new_template = '';

    // single post template
    if( is_single() ) {
      global $post;

      // template for post with video format
      if ( has_post_format( 'video' )) {
        // use template file single-video.php for video format
        $new_template = locate_template(array('single-video.php' ));
      }

    }
    return ('' != $new_template) ? $new_template : $template;
  }

Save the file. That's it.

Now just publish a post with video format & see the magic. You can do the same with every post format. On a related note, I'll also share the same trick with categories, instead of formats.

Add Post Formats To WordPress Theme

It's school holiday for five days in a row, so as a part of the second day of this holiday, I was doing some random stuff around the internet, such as listing to new songs, reading about upcoming Next-Gen gaming consoles, browsing troll memes, blaming Justin Bieber, and more.

So in this busy day I took some time to edit my WordPress website for new feature. I did some thing new (at least for me) with some post formats, and I'm going to share it here on BWidgets. So as a part of that tutorial, here's the basic thing to learn before I post that article, which is adding post format support to your WordPress theme.

Post Formats is a theme feature introduced with the WordPress 3.1 release. It's piece of meta info that can be used by a theme to customize its post structure. If you ever used Tumblr, then you'll love this feature.

As of now, WordPress supports following post formats:

  • aside: Typically styled without a title. Similar to a Facebook note update.
  • gallery: An image gallery. This type of post will likely contain an image gallery using shortcode and plugins.
  • link: A link to an external webpage.
  • image: A single image. Yeah, just a single image.
  • quote: A quatation. My favorite quote is: Your arms are just too short to box with the God. - CM Punk to Dwayne "The Rock" Johnson
  • status: A short status update, similar to a tweet.
  • video: A single video or several videos. You can upload or embed a video to the post.
  • audio: An audeo file, likely if you run a Podcast.
  • chat: A chat transcript.

Add following snippet to your theme's functions.php file to add post format support to your post:

add_theme_support( 'post-formats', array( 'aside', 'chat','gallery','image','link', 'quote', 'status', 'video', 'audio' ) );

You can also add post format support to Page and custom post types:

// add post-formats to post_type 'page'
add_post_type_support( 'page', 'post-formats' );

// add post-formats to post_type 'my_custom_post_type'
add_post_type_support( 'my_custom_post_type', 'post-formats' );

Sunday, 10 November 2013

How To Set Minimum Word Count For WordPress Posts

If you're running a WordPress site with some co-authors then it's really important for you to focus on your content's quality. Quality content is the ultimate key to success in blogging. Most of bloggers write like a monkey in the very beginning; I was also in that league when I started this blog.

Since recent Google updates you can no longer post an article with some couple of words and expect the post to rank highly for the keywords in the title. Now you need more content in the entire post with a lot of different keywords.

With WordPress you can create a function to make sure that you have a minimum number of words in your post.

By adding following code to your functions.php file, you can check if the post is under 500 words and if it is you can end the publishing process so the post will not be published:

function minimum_number_words($content)
{
    global $post;
    $content = $post->post_content;
    if (str_word_count($content) < 500 )
    wp_die( __('The current post is below the minimum number of words, it must be over 500 words.') );
}

Tuesday, 5 November 2013

Bulk Remove Featured Images From WordPress Posts

By default, there's no such option in WordPress to remove featured image from all posts at once. You can only remove the featured image by editing each post and removing it manually. It can take a lot of time. For example, it's almost impossible to manually remove featured images from my WWEFansNation.com with more than 4,000 posts. But that's all right cuz we're here to solve this problem.

WPBeginner found a great way to remove (unset) featured images from all posts in bulk. It's worth nothing that this code will only remove the featured image from the posts, and the image will not be deleted from your site.

Copy & paste following code in your theme's functions.php file:

global $wpdb;

$attachments = $wpdb->get_results( "
     SELECT *
     FROM $wpdb->postmeta
     WHERE meta_key = '_thumbnail_id'
" );

foreach ( $attachments as $attachment ) {
    wp_delete_attachment( $attachment->meta_value, true );
}

$wpdb->query( "
    DELETE FROM $wpdb->postmeta
    WHERE meta_key = '_thumbnail_id'
" );

Important: Please remove this code immediately after saving your functions.php file. You only need to run this code once, there's no need to keep this code in your theme.

Monday, 4 November 2013

Automatically Set The Featured Image In WordPress

Almost every WordPress theme developer is using WordPress' featured post image option in their latest themes, and it's a very great option. You can pick any image for your article before publishing

But ofter we forget to pick a featured image for out posts. Also there's no way to pick a featured image in WordPress' smartphone application. So today we're going to automatically set the featured image.

This snippet will automatically set the first image of your post as the featured image of the post. Note, you can always go and set another image as the featured image if you want to.

Add following snippet to your functions.php file:

function wpforce_featured() {
          global $post;
          $already_has_thumb = has_post_thumbnail($post->ID);
              if (!$already_has_thumb)  {
              $attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
                          if ($attached_image) {
                                foreach ($attached_image as $attachment_id => $attachment) {
                                set_post_thumbnail($post->ID, $attachment_id);
                                }
                           } else {
                                set_post_thumbnail($post->ID, '414');
                           }
                        }
      }  //end function
add_action('the_post', 'wpforce_featured');
add_action('save_post', 'wpforce_featured');
add_action('draft_to_publish', 'wpforce_featured');
add_action('new_to_publish', 'wpforce_featured');
add_action('pending_to_publish', 'wpforce_featured');
add_action('future_to_publish', 'wpforce_featured');

There is one more cool option in this code. If you don't have an image in the post, the above code will let you set a default featured image as well. You must edit the attachment ID according to your WordPress site. The example above uses the attachment ID "414"

Credits: WPForce

Tuesday, 8 October 2013

Add QR Code For Posts And Pages In WordPress

QR Code (Quick Response Code) is a great way to promote your content, and is very easy for users to use them. They can visit a webpage without even typing the entire web address. Just scan the QR Code and that's it.

The QR code system was invented in 1994 by Toyota's subsidiary, Denso Wave. Its purpose was to track vehicles during manufacture; it was designed to allow high-speed component scanning.[

Would you like to add a QR Code to your posts and pages in WordPress? It's easy just add the following snippet to your single.php file of your WordPress theme in the location you wish to display the QR.

<img src="http://api.qrserver.com/v1/create-qr-code/?size=100x100&data=<?php the_permalink(); ?>" alt="QR:  <?php the_title(); ?>"/>

To adjust the size of the QR Code just change the following within the src size=100×100.

Monday, 7 October 2013

Change Post Color By Status In WordPress Admin Panel

It's a great trick if you manage a WordPress site with multiple writers/contributors.It's a great trick if you manage a WordPress site with multiple writers/contributors.

Adding this snippet to your theme's functions.php file will change the background colors of the post / page within the admin based on the current status. Draft, Pending, Published, Future, Private.

add_action('admin_footer','posts_status_color');
function posts_status_color(){
?>
<style>
.status-draft{background: #FCE3F2 !important;}
.status-pending{background: #87C5D6 !important;}
.status-publish{/* no background keep wp alternating colors */}
.status-future{background: #C6EBF5 !important;}
.status-private{background:#F2D46F;}
</style>
<?php
}

Thursday, 19 September 2013

3 Ways To Disable WordPress AutoSave


This is my second post of the day here on BWidgets, and it's also about Daniel Bryan wp-config.php file and WordPress AutoPost. This time I'll show you one three ways to disable WordPress AutoSave feature.

When editing a post, the changes you make are automatically saved every 2 minutes. You can also use our last trick to Modify AutoSave Interval.

By Editing wp-config.php File:

This is the easiest way to disable WordPress AutoSave feature. To modify autosave interval simply open wp-config.php (located in root of WordPress installation) and add following code to the end of file:

define('AUTOSAVE_INTERVAL', 86400);

We've set WordPress AutoSave interval to 86400 seconds which is an entire day. So this effectively disables the autosave functionality. Thanks to Jacob Nicholson for the idea.

By Editing post.php File:

This is the smartest way to disable AutoSave feature without any heavy codes. Thanks to Shane G. for sharing this trick on a WordPress forum.

  • Open your wp-admin/post.php file and wp-admin/post-new.php files.
  • You will find this line of code there:

wp_enqueue_script('autosave');

  • Add // to the beginning of this code. It'll look something like this:

// wp_enqueue_script('autosave');

The AutoSave option will be disabled for your existing and new posts.

By Editing functions.php File:

Last but not the least. This is the most preferred way to disable this feature, as we don't have to re-edit our post.php and post-new.php file after every WordPress update, nor we have to adjust AutoSave interval. This trick will simple disable AutoSave feature. Thanks to Egill R. Erlendsson for sharing this trick on a WordPress forum.

Simple throw this in your functions.php file:

add_action( 'admin_init', 'disable_autosave' );
function disable_autosave() {
        wp_deregister_script( 'autosave' );
}

That's it folks. Thanks for all amazing guys that I mentioned on the article for sharing these amazing tricks around the internet. Don't forget to give us a backlink if you're sharing this article on your blog.

Modify WordPress AutoSave Interval


Here we're again! Another post about my favorite Pokemon WordPress core file. YES! YES! YES, this post is also about Daniel Bryan wp-config.php file.

When editing a post, the changes you make are automatically saved every 2 minutes. It seems bit weird, but you can actually change the setting for longer delays in between auto-saves, or decrease the setting to make sure you never lose changes.

And we don't need a crappy plugin for this simple hack. Technically, it's not even a hack, but a simple option described in original WordPress codex.

Modify WordPress AutoSave Interval:

To modify autosave interval simply open wp-config.php (located in root of WordPress installation) and add following code to the end of file:

define('AUTOSAVE_INTERVAL', 160 );  // seconds

Replace 160 with your custom autosave interval (in seconds).

Save your config.php file & that's it!

Friday, 13 September 2013

How To Disable Or Limit WordPress Post Revisions

Post Revisions are a feature introduced in WordPress 2.6. A revision is automatically stored in your database, whenever you save or draft a post or a page. Earlier this year, I posted an article about Deleting Old WordPress Post Revisions at this link.

Today we're going to learn a very simple tweak to disable or limit WordPress post revisions without installing any crappy plugin, which saves a lot of space. We just have to add a little snippet to your our config.php file.

Limit WordPress Post Revisions:

To limit Post revisions simply open wp-config.php (located in root of WordPress installation) and add following code to the end of file:

define('WP_POST_REVISIONS', 3);

Replace 3 with maximum number of Post revisions per post/page.

Disable WordPress Post Revisions:

To disable Post revisions simply open wp-config.php (located in root of WordPress installation) and add following code to the end of file:

define('WP_POST_REVISIONS', false );

 Save your config.php file & that's it!

Tuesday, 13 August 2013

How To Use Custom Post Thumbnail In Blogger


If you ever used self-hosted WordPress, then you might know about post thumbnail (featured post) feature. By using that feature, you can pick a custom image for your post's thumbnail, which is a great feature. I also use this feature on my wwefansnation.com.

I searched around the internet (just Google'd it) and found nothing like this for Blogger blogs. So I discover my own way to pick custom post thumbnail for Blogger. For this trick, we don't need any heavy JavaScript or CSS codes. It's a very little trick, even a newbie can easily use it.

By default, Blogger automatically uses first image of the article as post's thumbnail. So we'll add our thumbnail image to the top of our article, and we'll make it invisible with some CSS. Just add following html code to your post's top (in post editor's html editor):

<img src="Image-Link" style="display:none;"/>

Replace Image-Link with your image's link. Now your image will only appear as your post's thumbnail, and not in the post. This article is an example of this trick. You can visit archive pages to see this trick in action. Don't forget to post your comments.

Tuesday, 21 May 2013

Delete Old Post Revision In WordPress

Post Revisions are a feature introduced in WordPress 2.6. Whenever you or WordPress saves or drafts a post or a page, a revision of that version is automatically stored in your database. Each revision will slowly increase the size of your database. WordPress.com will store the last 25 revisions for each post.

For example, if you have 1 post and it has 10 revisions you could be storing up to 10 copies of older or unused data in your database, which will increase the size of your database for sure. You can learn more about Post Revisions by clicking here.

Now we know that these useless post revisions are just wasting our space. You can't delete these revisions manually, but the oldest revision is automatically deleted if there are more than 25 revisions.

Delete Post Revisions:

Delete Post Revisions is a great plugin to delete all useless post revisions off your database. It is compatible with the latest version of WordPress (3.x). It's coded by me, so don't forget to rate this plugin.

Here is the original description of Delete Post Revisions:

We created a tool which helps you to remove useless post revisions from your database.

Installing Delete Post Revisions:

  • Click here and download this plugin. Visit your WordPress' plugin page and install this plugin.
  • You can also install this plugin from your WP's plugin directory.
  • After installing, just click on active.

After installing, a new option will appear under the Settings tab. Not here is how to delete old post revisions:

  • Visit Settings > Delete Post Revisions
  • In the bottom, click on "Start" button and it's all done.

WordPress’ database queries don't retrieve revisions, so the number of revisions has no effect on the queries, but it's a great way of keeping your database clean. The only time the revisions are retrieved is on the edit page of the individual post.

Wednesday, 20 February 2013

Post Views Counter Widget For Blogger


Finally, MBT found a great way to display post view count on Blogger. We will do this by using Firebase. With Firebase you can now create dynamic and data-driven plugins for blogger without worrying about backend development. Firebase's Free plan gives you 10GB Free bandwidth and 5GB Free storage.

The postviews count wont change when you refresh the blog homepage but it will change only when you visit individual posts. This plugin will display views only once pages are visited. It is not synchronized with your Google analytics stats data, therefore it will only display correct views for the new posts that you publish.

Create Your Firebase Account And Database:

First you need to create a Firebase account to use this widget, which is free at this link. Fill up the easy steps sensibly and then once your account has been activated, you must create your first Firebase database.

  • Towards the bottom right side of your account, you will find the following submit box:

  • Inside this box input your desire firebase name. This generated the following firebase URL: https://example.firebaseio.com.

Installing Postviews Plugin:

  • Go To Blogger > Template > Click Edit HTML > Tick the box "Expand widget Templates"
  • Search for ]]></b:skin>
  • Just above it paste the following CSS code:

    /*-------- Post Views  ----------*/
    #views-container {
    width: 75px;
    float: right;
    }

    .mbtloading {
    background: url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc5Wn8iV8T3XKzrW6q_bia_k7TKh0Olhkl8t3snEMxjMLXElRyFILWr8vlzqaQyeMx4CCKXU1yifPts2an9fgbsWvzKelvzfq8AzWREJyE_TMDoipuGqvM5Cnb_Mga2hU4lj93XTxL8BE/s1600/loading.gif') no-repeat left center;
    width: 16px;
    height: 16px;
    }

    .viewscount {
    float: right;
    color: #EE5D06;
    font: bold italic 14px arial;
    }

    .views-text {
    float: left;
    font: bold 12px arial;
    color: #333;
    }

    .views-icon{
    background: url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhm_xSfbai8v-mrbnf6zQr3oVzBNQOKsIG4lse6IlGh2HQq2IRcMtIo5Ugigv-WFjlqKtmJyOKImqCVGfFlKBqgeMJtIK5UFwe4Mn9LIiQHkFnmxOB2Cgxe3PyP-1cklSbvqVDoiJmgAGE/s1600/postviews.png') no-repeat left;
    border: 0px;
    display: block;
    width: 16px;
    height: 16px;
    float: left;
    padding: 0px 2px;
    }

  • Now search for </body> and just above it paste the following JavaScript code:

<!-- Post Views Script by BWidgets -->
<script type='text/javascript'>
    window.setTimeout(function() {
        document.body.className = document.body.className.replace(&#39;loading&#39;, &#39;&#39;);
      }, 10);
  </script>
<script src='https://cdn.firebase.com/v0/firebase.js' type='text/javascript'/>
<script>
$.each($(&#39;a[name]&#39;), function(i, e) {
var elem = $(e).parent().find(&#39;#postviews&#39;).addClass(&#39;mbtloading&#39;);
var blogStats = new Firebase(&quot;https://example.firebaseio.com/pages/id/&quot; + $(e).attr(&#39;name&#39;));
blogStats.once(&#39;value&#39;, function(snapshot) {
var data = snapshot.val();
var isnew = false;
if(data == null) {
data= {};
data.value = 0;
data.url = window.location.href;
data.id = $(e).attr(&#39;name&#39;);
isnew = true;
}
elem.removeClass(&#39;mbtloading&#39;).text(data.value);
data.value++;
if(window.location.pathname!=&#39;/&#39;)
{
if(isnew)
blogStats.set(data);
else
blogStats.child(&#39;value&#39;).set(data.value);
}
});
});
</script>

  • Replace the example with your firebase name. Make sure you replace it correctly. Time for the final step.  Find this code:

<data:post.body/>

  • Just above it paste the following HTML,

<!-- Post Views Counter by BWidgets-->
<div id='views-container'><span class='views-icon'/><div class='views-text'>Views:</div> <div class='mbtloading viewscount' id='postviews'/></div>

  • Hit save and you are all done!

Having Trouble?

If you are finding multi occurrences of <data:post.body/> code then choose the first occurrence. Also, this widget will only display correct views for the new posts that you publish. Thanks to MBT for this amazing script.

Sunday, 17 February 2013

Recent Posts With Scrollbar Widget For Blogger


Finally, we are back with another widget with a generator. I was trying to find this widget for my blog since I started blogging, i never got success in searching this widget. Last night, I created this widget using recent-posts-with-titles-only.js script.

This awesome script is created by blogsolute.com, and modified by madtomatoe.com. With this widget you can show upto recent 25 posts of your blog in a small box. Width of this widget is 100%, which means it automatically adjusts on your blog's sidebar. If you're sharing this post then don't forget to give me a backlink.

Below is our Widget Generator with several fields:

Tuesday, 2 October 2012

Display Post Author, Date, Labels And Comments With Icons Below Post Titles


Today i'am sharing a great post by Helper Blogger. Here is a great widget to show author name , time , label and a comment bar with icons just below your blogger post titles. When there are no comments posted,the comment link says 'Be the First to comment!' and when there is just one comment it says '1 comment so far'. Here we go :

Installing :

  • Go To Blogger > Template > Edit HTML > Tick expand widget templates check box.
  • Now search for <div class='post-header-line-1'> and just above it paste following code :

<font style='background:transparent url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjavzoRG9bfyrjlRqJ-YEyq_E9VrXArh02J5-_Kb8Ks3jSRVE-e9Eg_gwUG0PjAP54kLQ9z8mJqF1zwkHX4gaMCp5yEChjTt1G5nCyNnyH-ry-san5I1-AeeqmH_YfL7S_aSBVoNG39D-U/s1600/author.gif) no-repeat scroll top left;padding-left:25px;font-size:11px;'><data:post.author/></font> | <font style='background:transparent url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnuBIJuJnKzy9R9IkTwPmSS4X0_5txI0Xsy9Ixk-Cwq6A5dQjXeylNir6xumH1L62aEpYl-cazDM0naaRoLofzdm1XygHP0OOg8jFYTieaUx5XbWBiZ9LH98h-ozsqTPoGg8ZVuJR2j4U/s1600/clock-icon.gif) no-repeat scroll top left;padding-left:25px;font-size:11px;'><data:post.timestamp/></font> | <font style='background:transparent url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDhdzvktxmxLTbsOUvVsExq9HzYnFON7p8OzGwvD4WaUqmdNhdyItxsiG5zEgiijnWRCpbnqZY7Vturb4Xl96iA9N3QqwzAuazWu9JBHdBALwx90YFXrbwb-VoPgk1XNHzrXTVokmZ_hU/s1600/tag+icon.gif) no-repeat scroll top left;padding-left:25px;font-size:11px;'><b:if cond='data:post.labels'>
<b:loop values='data:post.labels' var='label'>
<a expr:href='data:label.url + &quot;?max-results=8&quot;' rel='tag'><data:label.name/></a>
<b:if cond='data:label.isLast != &quot;true&quot;'>|</b:if>
</b:loop>
</b:if></font>
<span class='post-comment-link' style='Float:right;'>
        <b:if cond='data:blog.pageType != &quot;item&quot;'>
          <b:if cond='data:post.allowComments'>
            <a class='comment-link' expr:href='data:post.addCommentUrl' expr:onclick='data:post.addCommentOnclick' style='background:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-SZ6VJVZxY0nuGkWd1ezF5fF9s38C9wobjd8TBJMezWUjJ74Hr1WdOhhSzQRjYKJADrevDms8u42BUWEoo0ZB8DJ1XnJko5x69CYXdkpX3l85vo57wCEzjw2dCuxq7nO5vx7nYNvUQdo/s1600/comment-icon.png) no-repeat;Padding-left:20px;'><b:if cond='data:post.numComments == 0'>Be the first to comment!<b:else/> <b:if cond='data:post.numComments == 1'><data:post.numComments/> Comment so far<b:else/><data:post.numComments/> Comments so far</b:if> </b:if></a>
          </b:if>
        </b:if>
      </span>

Customizing :

  •  You can change all icons of this widget and also text to display then there is one or zero comments.

Wednesday, 12 September 2012

Related Posts Widget With Thumbnails For Blogger


Just realize that there are no related posts widget is on my blog. So I thought that I should add one for you guys. Here it is easy and beautiful. It's an eye catching widget which will give your visitor what they are looking for.

Installing :

  • Go To Blogger > Template > Edit HTML > Search for ]]></b:skin> :

#related-posts {
float : left;
width : 480px;
margin : 20px 0 20px;
padding: 5px;
}
#related-posts h2{
font-weight : normal;
color : #111;
font-family : "Nobile", "Helvetica Neue", Arial, Helvetica, sans-serif;
font-style : normal;
font-size:18px;
line-height: 24px;
padding:10px 10px;
margin:0;
}
#related-posts a {
border:1px solid #fff!important;
}
#related-posts a:hover {
background:#F2F2F5;
border:1px solid #CCC!important;
}

  • Now put the below script just above </head>

<script type='text/javascript'>
var defaultnoimage=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3UH4DFkEdnHZ1pnH4sc-n0sYyiKYS2Q5qWNuZfUnoM8mCOnyGs57pSs3tlX9RjZpFHJB0edAOBk7UGtvGFs-aVpTPXpKb4JtI-oRWZzfpNPgUjdsSlDq29b8yp_yrI52HvCux3ZLOYdo/s1600/noimage.png&quot;;
var maxresults=6;
var splittercolor=&quot;#d4eaf2&quot;;
var relatedpoststitle=&quot;Related Posts&quot;;
</script>
<script type='text/javascript'>
//<![CDATA[
var relatedTitles = new Array();
var relatedTitlesNum = 0;
var relatedUrls = new Array();
var thumburl = new Array();
function related_results_labels_thumbs(json) {
for (var i = 0; i < json.feed.entry.length; i++) {
var entry = json.feed.entry[i];
relatedTitles[relatedTitlesNum] = entry.title.$t;
try
{thumburl[relatedTitlesNum]=entry.media$thumbnail.url;}
catch (error){
s=entry.content.$t;a=s.indexOf("<img");b=s.indexOf("src=\"",a);c=s.indexOf("\"",b+5);d=s.substr(b+5,c-b-5);
if((a!=-1)&&(b!=-1)&&(c!=-1)&&(d!=""))
{thumburl[relatedTitlesNum]=d;} else {if(typeof(defaultnoimage) !== 'undefined') thumburl[relatedTitlesNum]=defaultnoimage; else thumburl[relatedTitlesNum]="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3UH4DFkEdnHZ1pnH4sc-n0sYyiKYS2Q5qWNuZfUnoM8mCOnyGs57pSs3tlX9RjZpFHJB0edAOBk7UGtvGFs-aVpTPXpKb4JtI-oRWZzfpNPgUjdsSlDq29b8yp_yrI52HvCux3ZLOYdo/s1600/noimage.png";}
}
if(relatedTitles[relatedTitlesNum].length>42) relatedTitles[relatedTitlesNum]=relatedTitles[relatedTitlesNum].substring(0, 35)+"...";
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'alternate') {
relatedUrls[relatedTitlesNum] = entry.link[k].href;
relatedTitlesNum++;
}
}
}
}
function removeRelatedDuplicates_thumbs() {
var tmp = new Array(0);
var tmp2 = new Array(0);
var tmp3 = new Array(0);
for(var i = 0; i < relatedUrls.length; i++) {
if(!contains_thumbs(tmp, relatedUrls[i]))
{
tmp.length += 1;
tmp[tmp.length - 1] = relatedUrls[i];
tmp2.length += 1;
tmp3.length += 1;
tmp2[tmp2.length - 1] = relatedTitles[i];
tmp3[tmp3.length - 1] = thumburl[i];
}
}
relatedTitles = tmp2;
relatedUrls = tmp;
thumburl=tmp3;
}
function contains_thumbs(a, e) {
for(var j = 0; j < a.length; j++) if (a[j]==e) return true;
return false;
}
function printRelatedLabels_thumbs(current) {
var splitbarcolor;
if(typeof(splittercolor) !== 'undefined') splitbarcolor=splittercolor; else splitbarcolor="#d4eaf2";
for(var i = 0; i < relatedUrls.length; i++)
{
if((relatedUrls[i]==current)||(!relatedTitles[i]))
{
relatedUrls.splice(i,1);
relatedTitles.splice(i,1);
thumburl.splice(i,1);
i--;
}
}
var r = Math.floor((relatedTitles.length - 1) * Math.random());
var i = 0;
if(relatedTitles.length>0)document.write('<h2>'+relatedpoststitle+':</h2>');
document.write('<div style="clear: both;"/>');
while (i < relatedTitles.length && i < 20 && i<maxresults) {
document.write('<a style="text-decoration:none;padding:5px;float:left;');
if(i!=0) document.write('border-left:solid 0.5px '+splitbarcolor+';"');
else document.write('"');
document.write(' href="' + relatedUrls[r] + '"><img style="width:125px;height:125px;padding:2px;border:solid 1px #eaeaea;" src="'+thumburl[r]+'"/></a>');
i++;
if (r < relatedTitles.length - 1) {
r++;
} else {
r = 0;
}
}
document.write('</div>');
relatedUrls.splice(0,relatedUrls.length);
thumburl.splice(0,thumburl.length);
relatedTitles.splice(0,relatedTitles.length);
}
//]]>
</script>

  • Now click on 'Expand Widget Templates' and search for <div class='post-footer-line post-footer-line-2'> and put the following code after <div class='post-footer-line post-footer-line-2'> :

<b:if cond='data:blog.pageType == &quot;item&quot;'>
<div id='related-posts'>
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.isLast != &quot;true&quot;'>
</b:if>
<script expr:src='&quot;/feeds/posts/default/-/&quot; + data:label.name + &quot;?alt=json-in-script&amp;callback=related_results_labels_thumbs&amp;max-results=9&quot;' type='text/javascript'/></b:loop>
<script type='text/javascript'>
removeRelatedDuplicates_thumbs();
printRelatedLabels_thumbs(&quot;<data:post.url/>&quot;);
</script>
</div><div style='clear:both'/>
<!-- remove --></b:if>
<b:if cond='data:blog.url == data:blog.homepageUrl'><b:if cond='data:post.isFirstPost'/></b:if>

Note : If you can't find <div class='post-footer-line post-footer-line-2'> code, you can also look for <data:post.body/> and put code on point 5 after <data:post.body/>

Wednesday, 15 August 2012

"Link To This Post" Widget Below Posts In Blogger

Everyone loves great content except Usher cuz he loves Bieber content anyways. Last month i posted an article Short URL Widget Below Posts In Blogger which was cool but this one is more easy to add.

  • Go To Blogger > Template > Edit HTML > Check 'Expand Widget Template'
  • Find <data:post.body/> in your template
Note - If you can't find or add this widget by using <data:post.body/> then find <div class='post-footer-line post-footer-line-1'/> or <div class='post-footer'> and just above it post code given below :


<b:if cond='data:blog.pageType == "item"'>
<p style='color: #7AA1C3;font-weight: bold;'>If you Like This Article,Then kindly linkback to this article by copying one of the codes below.</p>
<p style='color: #CF152A;font-weight: bold;'>URL Of Post:
</p><textarea cols='60' id='url' onclick='this.focus();this.select()' readonly='readonly' rows='2' style='border:2px solid #666;background:#fff; height: 2.6em; width: 98%;' title='Click to highlight'><data:post.url/></textarea><br/>
<br/><p style='color: #CF152A;font-weight: bold;'>Paste This HTML Code On Your Page:</p>
<textarea cols='60' id='HTML-code' onclick='this.focus();this.select()' readonly='readonly' rows='2' style='border:2px solid #666;background:#fff; height: 2.6em; width: 98%;' title='Click to highlight'>&lt;a href=&quot;<data:post.url/>&quot;&gt;<data:post.title/>&lt;/a&gt;</textarea>
</b:if>

  • Save template
Just visit your post and see if it's working.....

Saturday, 14 July 2012

Short URL Widget Below Posts In Blogger


So in this tutorial we'll learn adding short url widget below posts.....it's totally awesome and gives your visitors short links of your blogger posts.....


  • First get Bit.ly's API you need to sign in there to get your api.
  • After getting AIP Go To Blogger > Template > Edit HTML
  • In Edit HTML press Ctrl+F and find </head>
  • Post following script just above  </head>.
<script type="text/javascript" charset="utf-8" src="http://bit.ly/javascript-api.js?version=latest&amp;login=YOURUSERNAME&amp;apiKey=YOURAPIKEY"></script>
<script type="text/javascript" charset="utf-8">
BitlyClient.addPageLoadEvent(function(){
BitlyCB.myShortenCallback = function(data) {
// this is how to get a result of shortening a single url
var result;
for (var r in data.results) {
result = data.results[r];
result['longUrl'] = r;
break;
}
document.getElementById("shorturl").innerHTML = "Share this link: &lt;input type='text' value='" + result['shortUrl'] + "' name='bitlyurl'/&gt;";
}
BitlyClient.shorten(document.location, 'BitlyCB.myShortenCallback');
});
</script>

  • Replace  YOURUSERNAME And YOURAPIKEY with your bit.ly Username and API(Follow First Step)
  • Now Find ]]></b:skin>  and just above it post following script
form#shorturl {
color:#666;
font-size:11px
}#shorturl input {
color:#999;
border:1px inset #CDCDCD;
padding:1px 5px;
}
  • Save Template
  • Now again click on Edit HTML and mark Expand the Template.
  • Find :
<div class='post-footer-line post-footer-line-3'>
</div>
  • And post following script just between above code
<b:if cond='data:blog.pageType == "item"'>
<form id='shorturl'/>
</b:if>
  • Click on Save Template and just visit your posts to see this script in action.
Comment for any type of help..... :)

Popular Posts

 
Powered by Blogger.