WordPress is undoubtedly one of the most popular tools on the Internet because it makes it so easy to get a functional web site up and running in such a short time.
And then there are the plugins. If you want your WordPress site to do something then odds are there is a plugin that you can install to make your site do what you want it to do.
But plugins pose a bit of a problem at times. Since they are created by third-party developers you never know what quality control practices are used and what security testing is done to make sure that the plugin doesn’t leave your site vulnerable.
So instead of blindly installing a plugin, you can easily apply these hacks to your WordPress code to enhance the functionality of your site without giving up control to a plugin developer who you don’t know.
Remove the trackbacks from your comment count
Like any exercise, let’s get warmed up first.
Trackbacks are one of the communication tools that make blogging much more community driven than a static web site. However because they are listed under the comments, people don’t always approve them. This quick little hack will remove the trackbacks your blog receives from the total number of comments.
This can be done by adding the following code to the functions.php file:
add_filter('get_comments_number', 'comment_count', 0); function comment_count( $count ) { if ( ! is_admin() ) { global $id; $comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id)); return count($comments_by_type['comment']); } else { return $count; } }Keep readers on your site with related posts
Most blog owners know that best way to keep visitors is to provide them with more useful content. There are many plugins out there that can be used to provide readers with related posts, but it is also something that can be done with a little bit of custom code that needs to be placed within the loop:
<?php $tags = wp_get_post_tags($post->ID); if ($tags) { echo 'Related Posts'; $first_tag = $tags[0]->term_id; $args=array( 'tag__in' => array($first_tag), 'post__not_in' => array($post->ID), 'showposts'=>5, 'caller_get_posts'=>1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><a href="<?php the_permalink() ?>" rel="bookmark" title=" Permanent Link...