Post Views Snippets

function setPostViews($postID) {
    $count_key = 'views';
    $count = get_post_meta($postID, $count_key, true);
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        update_post_meta($postID, $count_key, $count);

Paste the below code in the single page, so that it count your views.

PHP, Wordpress

Display External RSS Feeds in our Site

Here is the code for displaying External RSS Feeds in our Worpdress Site.

<?php include_once(ABSPATH.WPINC.'/feed.php');
$rss = fetch_feed('Feed URL Goes Here');
$maxitems = $rss->get_item_quantity(4);
$rss_items = $rss->get_items(0, $maxitems);
<ul style="font-family:Helvetica;font-size:15px;list-style:square;">
<?php if ($maxitems == 0) echo '<li>No items.</li>';
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<a href='<?php echo $item->get_permalink(); ?>'
title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>' target="_blank">
<?php echo $item->get_title(); ?></a>
<?php endforeach; ?>

Keep Spreading…


Display the number of your Twitter Followers

Here is the code for display the number of followers who are following you on twitter.

Copy and Paste the below code in ‘functions.php’ file.

function string_getInsertedString($long_string,$short_string,$is_html=false){
  if($short_string>=strlen($long_string))return false;
  if($is_html && $inserted_string[$insertion_length-1]=='<'){
  return $inserted_string;

function DOMElement_getOuterHTML($document,$element){
  return string_getInsertedString($html,$html2,true);

function getFollowers($username){
  $x = file_get_contents("http://twitter.com/".$username);
  $doc = new DomDocument;
  $ele = $doc->getElementById('follower_count');
  return $innerHTML;

And then copy and paste the below code to display the number of followers count.

<?php echo getFollowers("your twitter username")." Followers"; ?>

Keep Sharing and njoy.

Display WordPress comments in wordpress

I was trying to figure out, how i can display wordpress comment with a help of little coding..

<div class="post-recent-comment" style="font-size: 13px; font-weight: bold; font-family: Arial,helvetica;>


$comment_array = array_reverse(get_approved_comments($wp_query->post->ID));

$count = 1;


<?php if ($comment_array) { ?>

<span class="comment"><?php comments_number('No comment','1 comment','% comments'); ?></span> – Latest by:

<ul class="commentlist"”>

<?php foreach($comment_array as $comment){ ?>

<?php if ($count++ <= 10) { ?>

<li><?php echo($comment->comment_author . '<br />' . $comment->comment_content); ?></li>

<?php } ?>

<?php } ?>


<?php } else { ?>

<span class="comment">No comments so far</span>

<?php } ?>


Seperate a String variable with the delimiters

I have been trying to fix a gallery of images in my project. Atlast i have landed up with a solution we can get the collection of a images Url seperated with commas and then make it stored in the array variable and retrieve it back.

$image=get_post_meta($post->ID, 'custom field name', true);
<a href="<?php if((($img[$i] == substr($img[$i],0,57).''.'.jpg'))) { echo substr($img[$i],0,57).''.'_b.jpg'; } else { echo substr($img[$i],0,57).''.'_b.jpg'; } ?>"><img src="<?php if((($img[$i] == substr($img[$i],0,57).''.'.jpg'))) { echo substr($img[$i],0,57).''.'_m.jpg'; } else { echo substr($img[$i],0,57).''.'_m.jpg'; } ?>" style="width:172px;"/></a>

Thanks for my dream one.