How To Export Articles From A Selected Category

The Wordpress CMS comes with Export/Import feature for us to export our blog posts from one website and import to another website. However, the default Export feature only allow us to export posts from a selected author.

I found one interesting request from digitalpoint forum. The user requests someone to modify the default Wordpress files so that he can exports posts from a selected category. I had tried to modify the files, found the solution and i would like to share it with my readers (I didn’t make any profit from him and someone had already sold his solution for that guy).

We need to modify the wp-admin/export.php and wp-admin/includes/export.php. Make sure you do a backup of your Wordpress database and these two files before you continue.

wp-admin/export.php

First of all, let’s start with wp-admin/export.php. Open your with wp-admin/export.php with any text editor, and search for

if ( isset( $_GET['download'] ) ) {
export_wp( $_GET['author'] );
die();
}

Replace with

if ( isset( $_GET['download'] ) ) {
export_wp( $_GET['category'] );
die();
}

Next, search for

<table class="form-table">
<tr>
<th><label for="author"><?php _e('Restrict Author'); ?></label></th>
<td>
<select name="author" id="author">
<option value="all" selected="selected"><?php _e('All Authors'); ?></option>
<?php
$authors = $wpdb->get_col( "SELECT post_author FROM $wpdb->posts GROUP BY post_author" );
foreach ( $authors as $id ) {
$o = get_userdata( $id );
echo "<option value='$o->ID'>$o->display_name</option>";
}
?>
</select>
</td>
</tr>
</table>

Replace with

<table class="form-table">
<tr>
<th><label for="category"><?php _e('Restrict Category'); ?></label></th>
<td>
<select name="category" id="category">
<option value="all" selected="selected"><?php _e('All Categories'); ?></option>
<?php
$categories = (array) get_categories('get=all');
foreach ( $categories as $c ) {
echo "<option value='$c->term_id'>$c->cat_name</option>";
}
?>
</select>
</td>
</tr>
</table>

wp-admin/includes/export.php

Next, open your wp-admin/includes/export.php and search for

function export_wp($author='') {

Replace with

function export_wp($cat='') {

Next, search for

if ( $author and $author != 'all' ) {
$author_id = (int) $author;
$where = $wpdb->prepare(" WHERE post_author = %d ", $author_id);
}

Replace with

if ( $cat and $cat != 'all' ) {
$cat_id = $cat;
$ids = $wpdb->get_col("SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id=$cat");
$where = $wpdb->prepare(" WHERE ID IN(".join(',',$ids).")");
}

Explanation

Basically, what you are doing is just replace the “author” with “category“. The default codes will query the available authors while my codes query the available categories.

The second file plays the most important role. It is a bit complicate to explain step by step. But basically, I will query the post ID that match the selected category ID and save the SQL query string in a $where variable. The $where string will be used in the subsequent codes, which we no need to modify.

I hope you guys can understand what i trying to explain. I had prepared a zip file that contains both of the modified files. You may download it and replace with the original files.

Note: I had tried this hack on Wordpress 2.6.2 only and i don’t know whether it works on other version or not. Please make a backup of these two files before you try!

Download: wp-admin.zip

Replace Your Default Gravatar With Some Meaningful Images

Gravatar stands for Globally Recognize Avatar. It is basically an image following you from weblog to weblog as long as you use the same email address to comment.

Before Wordpress 2.5, you need to install plugin in order to use Gravatar in your blog. But after Wordpress acquired Gravatar and released Wordpress 2.5, Gravatar became an inbuilt feature.

To use Gravatar, you simply call this:

<?php echo get_avatar( $comment, 50 ); ?>

But, do you know that you can replace the default avatar with a more meaningful image? Actually, Gravatar supports Identicons, MonsterID, and Wavatars. You may set your default avatar to use one of them. So, if your reader doesn’t has a gravatar account, the system will automatic generates an image for him.

Below are some examples of using Identicons, MonsterID, and Wavatars as your default gravatar:

<?php echo get_avatar( $comment, 50, $default = 'identicon ' ); ?>
<?php echo get_avatar( $comment, 50, $default = 'monsterid ' ); ?>
<?php echo get_avatar( $comment, 50, $default = 'wavatar' ); ?>

The output avatar is depends on the commenter’s email address. So, the same commenter will always get the same avatar image.

I had set the default Gravatar to use Wavatars so now each of my commenter will have hos own unique avatar.

How To Hide Feedburner Feed Count

There are some bloggers who don’t want to show their Feedburner’s Feed Count to visitor. This may be due to their blogs still new and don’t have much subscribers. Normally these bloggers will simply replace the FeedCount widget with an a link to their Feedburner link.

Unfortunately, this method don’t really “hide” the feed count. Why i said so? It is because people can still view your feed count by using this url:

http://feeds.feedburner.com/~fc/feedID

Simply replace the feedID with the target Feedburner account ID and you will see the FeedCount widget appear in front of you.

So, how you hide this number before you have enough confident to show off your subscribers? Go to your Feedburner account page, and browse to the Publicize tab. After that, go to FeedCount and deactivate this service.

Tips: Bloggers are advised to hide their feed count before they get 300 subscribers.

Use Top Commentator Widget To Boost Comments

Top Commentator Widget is a handy tool for blogger to show their thankfulness to active commentators. With this widget, you can place a widget at your sidebar and show your active commentators to your visitors.

Top commentator Widget can encourage people to comment on your blog. Why i say so? People visit your blog frequently and leave quality comments, you return a favor to them by displaying their names and links at your sidebar. So, people are more willing to leave comments on your blog.

After you download and activate the plugin, you need to go to the Widget are and add it to your sidebar. After this, you can edit the settings. There are few settings which need your attention before activate this plugin:

  • Widget title
  • Exclude user
  • Reset the list
  • The number of names shown
  • Hyperlink each name
  • NoFollow hyperlink

The default Widget title is blank. So, you may simply put “Top Commentators” as your Widget title. The second thing that you need to configure is exclude yourself and other authors in the list. Your name will always at the first place if you don’t exclude yourself. If you are the visitor, what would you think?

The best period to reset your Top Commentator list is every one month or bi-weekly. It is all depands on number of comments on your blog. Next, you need to decide how many names to be shown in the list and whether want to hyperlink each name or not. I suggest you hyperlink each name to show your love to those top commentators. However, if you afraid doing so will affect your Google ranking, you may consider turn on the “NoFollow” for each hyperlink.

Download : Top Commentator Widget

Page 2 of 2«12