FacebookTwitter

How to Display Total Number of Comments in WordPress

By on Dec 14, 2010 in Wordpress Tutorials |

Many of you may have seen blogs who display total comments on their blog and ever wanted to do the same? Its easy yea its super easy if you want to display total number of comments in wordpress then just follow the steps below. To display total number of comments in wordpress you will need a short snippet of PHP code which we are sharing here. To display total number of comments in wordperss all you will need to do is open your sidebar.php file or any other file where you want to display, and paste the following code: <?php $commcount = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); if (0 < $commcount) $commcount = number_format($commcount); echo "Our users have made ".$commcount." comments, care to join in?"; ?> You can style the code as per your desired...

How to Separate Trackbacks from Comments in WordPress

By on Dec 14, 2010 in Wordpress Tutorials |

By default wordpress does not shows trackbacks and comments separately but there is a hack which is used to show comments and trackbacks separately. Its good to show comments and trackbacks separately as it makes the comments section clean and clutter free.If you want to seperate trackbacks from comments then follow the steps below. Open and edit the comments.php file of your theme. Find the comment loop: foreach ($comments as $comment) : ?> // Comments are displayed here endforeach; Replace it with the following: <ul> <?php //Displays comments only foreach ($comments as $comment) : ?> <?php $comment_type = get_comment_type(); ?> <?php if($comment_type == 'comment') { ?> <li>//Comment code goes here</li> <?php } endforeach; </ul> <ul> <?php //Displays trackbacks only foreach ($comments as $comment) : ?> <?php $comment_type = get_comment_type(); ?> <?php if($comment_type != 'comment') { ?> <li><?php comment_author_link() ?></li> <?php } endforeach; </ul> And you are done from now on the comments and trackbacks will be displayed...

How to Reverse Comments Order in WordPress

By on Dec 14, 2010 in Wordpress Tutorials |

By default wordpess shows the comments in order of older first and the newer at last.Many bloggers want to reverse this order to show newer comments first and older comments at last. If you also want to do the same its so easy just follow the steps below to reverse comments order in wordpress. Just open the comments.php file located in your theme folder. Find the following line: <?php foreach ($comments as $comment) : ?> Now, add this line below: <?php $comments = array_reverse($comments, true); ?> The code should look like : <?php $comments = array_reverse($comments, true); ?> <?php foreach ($comments as $comment) : ?> // comments loop <?php endforeach; ?> That’s all. Comments will now be displayed in reverse...

How to Allow Contributors to Upload Files in WordPress

By on Dec 14, 2010 in Wordpress Tutorials |

If you have a blog where people contribute posts then you may have noticed that contributors can’t upload files in wordpress.Its the lack of their rights that wordpress does not allows contributors to upload files. Its necessary that contributors can upload files so they can put image or video within the post and if you want to allow contributors to upload files in wordpress here is a quick hack. Just paste the code below in functions.php file of your theme: if ( current_user_can('contributor') && !current_user_can('upload_files') ) add_action('admin_init', 'allow_contributor_uploads'); function allow_contributor_uploads() { $contributor = get_role('contributor'); $contributor->add_cap('upload_files'); } You are done now contributors can upload files in...

How to Automatically Empty Trash in WordPress

By on Dec 14, 2010 in Wordpress Tutorials |

Trash is the new feature in wordperss and it arrived in wordperss 2.9 whenever someone deletes a post, page, comment etc. that doesn’t gets deleted permanently that is stored in trash so if the deletion is done by mistake then the deleted item can be restored. But when you delete lots of items it becomes bulk of unusable data stored in your wordpress database.To get rid of this you can opt to choose empty trash after certain interval of time to. Here is a small tip to automatically empty trash in wordpress follow the steps below to do the same. Open wp-config.php file located at the root of your WordPress install and paste the following code: define('EMPTY_TRASH_DAYS', 10 ); The parameter ’10’ is when to empty trash, in days, you can change it as per your...

How to Add Facebook “Like” button in WordPress

By on Dec 14, 2010 in Wordpress Tutorials |

Facebook is the largest social network with millions of registered users if your content is shared over facebook by many facebook users that will gain good amount of traffic. To make it easy to share your content on facebook you can add Facebook like button to your wordperss blog.Follow the instructions below to add facebook like button in wordpress. Open single.php file or any or any file where you’d like the button to be displayed and paste the code shown below. <iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:60px;"></iframe> If you want to show the friend icons under the button, then use: show_face=true If you want to display the simple button with only the count and nothing else, then use: layout=button_count If you want dark color scheme for your button, then use : colorscheme=dark If you want to change the text from Like to Recommend, then use : action=recommend You can customize the width of the iFrame as of your...