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.

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 Backup and Restore WordPress Database

Please keep in mind that you need to backup your wordpress database periodically to prevent your data lose in case of bad plugin installation or an attack by hacker. So do you know how to backup and restore your wordpress database? If you don’t, let me show you how.

DISCLAIMER: I will not going to hold responsible in any way should you encounter problems like loss of database and entire blog/website along the way. It worked excellently well for me.

How to Backup Your WordPress Database

1. Download and install WordPress Database Plugin and active this plugin.

2. In your wordpress dashboard, go to Tools > Backup

3. Under Backup Options, select “Download to your computer” and click on “Backup Now” button.

How to Restore Your WordPress Database

1. Log into your FTP account and delete everything in the /wp-content/cache directory.

2. Log into PHP MyAdmin and select your wordpress database.

3. A list of all of the tables contained in the database will be shown. Select all the tables and select the Drop option to delete them permanently.

4. After wordpress database is empty, it is time to upload your database by clicking Import tab.

5. Locate of the text file and then click “Go” button to import your wordpress database.

Ecommerce Glossy Icon Set

Freebies icon set again! This time is e-commerce icon set (Ecommerce Glossy) that created by IconShock.com. For those people who are planning to run e-commerce website, perhaps this e-commerce icon set is the right choice for you.

Ecommerce Glossy e-commerce icon set consists of 21 different e-commerce related icons in total and comes few different formats, I.e., high quality Adobe Illustrator .AI, Photoshop .PSD as well as .PNG.

You can download Ecommerce Glossy for free, but you can’t redistribution or re-selling.

You Can’t Change Facebook URL That Has Been Set

If you haven’t set your facebook url, you can go to http://www.facebook.com/username to set your default facebook url, there are several steps that you need to go for it for setting new facebook url. Recently, I was thinking to change facebook url, and I kept searching the option from facebook to change facebook url, but unfortunately there is no other way round to change facebook url that has been set. Hmm.. It is looks like I need to deactivate my current facebook account and create a new facebook account if I insist want to change facebook url. 

Remind Your Eyes Rest with Eyes Relax

Once I play online game, I can play few hours and even more than 10 hours, it is seem like I have crazy life. I know there is one software named Eyes Relax can helps avoiding eyes-related problems when working at a computer for several hours, it can reminds me about taking those break, but I think it’s seem not useful for me.

Anyway, if you have children at home, and you want to control their computer playing time, then Eyes Relax is very helpful as it can enter the password-protected Parent Mode in which the user is forced to take breaks (during the break the computer is locked). This is very useful since children often forget about the real world and play video games much too long.

If you don’t have too much time to monitor your children playing computer, then you can try Eyes Relax to lock their computer and stop them play computer at your desired time.

Faster Way to Resize Your Images

For those people who like to share your photos with their friends and family as well as upload images Facebook, photo albums and etc, perhaps you can check out these two light weight programs that resize and change the format of the image files. Although they don’t have powerful features like Photoshop software, but they are no-frills utility that’s nice to have for quick, basic photo edits.

1) Easy Image Modifier (Free)

  • Modify batches of images with just a few mouse-clicks
  • Load and save images in the common Jpg, Png, Bmp formats
  • Resize, realign, change format, rename etc.
  • Advanced options: Sort, resize unproportional, remove meta information, set Jpg compression level
  • Multilingual
  • Portable: Just one executable, no need for installation.

    2) Image Resizer (Free)

  • It enables you to resize one or many image files with a right-click.
  • This version will work also on non-XP versions of Windows including Windows Vista.
  • How to Display Most Recent Twitter Tweets in WordPress Blog

    Since Twitter became popular, many bloggers like to display recent twitter tweets on their website or blog. To display most recent twitter tweets, simply copy and paste the following code to your sidebar.php file.

    <?php
    // Your twitter username.
    $username = "TwitterUsername";
    // Prefix - some text you want displayed before your latest tweet.
    // (HTML is OK, but be sure to escape quotes with backslashes: for example href=\"link.html\")
    $prefix = "";
    // Suffix - some text you want display after your latest tweet. (Same rules as the prefix.)
    $suffix = "";
    $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
    function parse_feed($feed) {
    $stepOne = explode("<content type=\"html\">", $feed);
    $stepTwo = explode("</content>", $stepOne[1]);
    $tweet = $stepTwo[0];
    $tweet = str_replace(”&lt;”, “<”, $tweet);
    $tweet = str_replace(”&gt;”, “>”, $tweet);
    return $tweet;
    }
    $twitterFeed = file_get_contents($feed);
    echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
    ?>

    Thanks the awesome code from WP Hacks.

    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 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();
    ?>