How to Seperate Comments and Trackbacks

Most wordpress themes combine comments with trackbacks, if you want to separate comments and trackbacks so that it will looks more organized, then you can follow the below step by step guide.

Step 1

Open comments.php and look for

<?php foreach ($comments as $comment) : ?>

Paste after

<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>

Step 2

Scroll down a bit and look for

<?php endforeach; /* end for each comment */ ?>

Paste before

<?php } else { $trackback = true; } /* End of is_comment statement */ ?>

Step 3

Look for

<?php else : // this is displayed if there are no comments so far ?>

Paste before

<?php if ($trackback == true) { ?>
<h3>Trackbacks</h3>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type != 'comment') { ?>
<li><?php comment_author_link() ?></li>
<?php } ?>
<?php endforeach; ?>
</ol>
<?php } ?>

How to Display Categories in Drop-Down Box

Personally, I prefer to display my blog categories without in drop down box, but if you really have many categories on your blog, perhaps you can display categories in drop-down box so that your blog will looks more neat.

Below is the simple code to display categories:-

<h2>Categories</h2>
<ul>
<?php wp_list_cats('sort_column=name'); ?>
</ul>

To display categories in drop-down box, use the following code.

<form action="<?php bloginfo('url'); ?>/" method="get">
<?php
$select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0');
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select); echo $select; ?>
<noscript><input type="submit" value="View" /></noscript>
</form>

How to Exclude Certain Categories

There are 2 ways to exclude certain categories from your blog, one is use wordpress plugin named Advanced Category Excluder. This plugin was born because there was a no other real alternative to enable content sparationd and some CMS like functionalities in WordPress. The main goal was, to enhance WordPress’s functionalities, to hide some unwanted categories, from defined parts of the blog.

The alternative way is without plugin, you can add the below code inside the loop then it will work.

<?php
if ( have_posts() ) : query_posts($query_string .'&cat=-1,-2'); while ( have_posts() ) : the_post();
?>

Image Caption – Put Caption Under Your Images

If you want to put the caption under your images, then you can make use of Image Caption wordpress plugin. This plugin extracts the title or alt attribute from images within your blog post and generates a neat caption directly underneath those images. Apart from that, it also supports custom CSS styling for captions.

How to Highlight Author’s Comments

There are 2 ways to highlight author’s comments, one is use highlight author comments wordpress plugin, another idea is without wordpress plugin. If you don’t want to use wordpress plugin to highlight author’s comment, you can follow the below few simple steps.

First, you need to open styles.css and add the following into this file.

.authorstyle { background-color: #B3FFCC !important; }

Second, open comments.php, find and locate the following code.

<li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"></li>

And then replace with

<li class="<?php if ($comment->user_id == 1) $oddcomment = "authorstyle"; echo $oddcomment; ?>"></li>

Please note that you must change 1 to the user id of the author. Thanks to Matt Cutts for this tutorial.

How to Display Recent Posts from Specific Category

Initially I was thinking to display all the posts from specific category in my archives page, but this doesn’t work well if you have thousand of posts for one category, that’s why I want to limit the number of recent posts displayed from specify category.

To display recent posts from specific category, you can make use of the following coding. To change the number of displayed recent posts, simply change the showposts=10 to your desired number; cat=1 is your category number, you have to change this too.

<ul>
<?php $recent = new WP_Query("cat=1&amp;showposts=10"); while($recent->have_posts()) : $recent->the_post();?>
<li><a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?>
</a></li>
<?php endwhile; ?>
</ul

In case you need to display all posts from specific category, then you can use the following coding. cat=6 is your category number, please change it.

<ul>
<?php query_posts('cat=6'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php $wp_query->is_home = false; ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a> – <?php the_time('j F Y') ?></li>
<?php endwhile; endif; ?>
</ul>

Thanks to Ready WP Themes for this coding.