Showing posts with label WordPress. Show all posts
Showing posts with label WordPress. Show all posts

Wednesday, March 25, 2009

XML Sitemap Generator for WordPress: Error loading stylesheet

XML Sitemap Generator for WordPress is a great WordPress plugin for generating XML sitemap. However, recent update of the plugin caused an error in viewing the XML file via Web browser.

Error loading stylesheet: An XSLT stylesheet does not have an XML mimetype:

To fix it, add

AddType application/xml .xsl

to the .htaccess file.

Saturday, March 7, 2009

Valid ampersand when writing URLs in HTML

Always use & in place of & when writing URLs in HTML.

Example of invalid ampersand for URL in HTML:
<a href="test.php?var1=3&var2=6&var3=10">...</a>

The correct usage:
<a href="test.php?var1=3&amp;var2=6&amp;var3=10">...</a>

To validate for markup, please use W3C Markup Validator.

Monday, February 23, 2009

Compact Digg button for WordPress

A code to embed a compact Digg button (as shown in Figure 1) in WordPress.

[caption id="attachment_1521" align="alignnone" width="450" caption="Figure 1: A compact Digg button"]A compact Digg button[/caption]
<script type="text/javascript">
digg_url = '<?php echo get_permalink(); ?>';
digg_title = '<?php the_title(); ?>';
digg_skin = 'compact';
digg_window = 'new';
<script src="" type="text/javascript"> </script>

Tuesday, February 3, 2009

How to reset WordPress admin password

One morning, you figured out that you can't log in to your blog admin panel. Perhaps, you had forgotten the password, or someone must have messed up with your blog. You can retrieve the lost password by going to the WordPress Log In page, and click on the 'Lost your password?' link. On the next page, enter the admin username or E-mail, and click 'Get New Password', as shown in Figure 1.

Figure 1: Retrieve password

A new password will be sent to the E-mail that you specified during the registration process.

If the above method fails. You can also reset the password using the phpMyAdmin tool. Open the phpMyAdmin tool via cPanel. Once you are in phpMyadmin, select your WordPress database, from the left menu. Next click on the SQL tab, which is located at the top. Paste the SQL code below, inside the text area. Replace 'your new password' with the new password, and 'the admin username', with the existing username of the admin account. Please refer to Figure 2.
UPDATE `wp_users` SET `user_pass` = MD5( 'your new password' )
WHERE `wp_users`.`user_login` = "the admin username";

Figure 2: Reset admin password

I hope that this article will benefit those who lost their blog password. Good luck.

Monday, February 2, 2009

2 ways to disable trackbacks in WordPress

Trackbacks is a WordPress feature that will notify a blog when your blog publish an entry that references it. A link with a short excerpt of your blog entry will appear on the referenced blog. Unfortunately, Spam Bots usually use the trackbacks feature to deliver spams. However, you can actually disable it. To disable trackbacks, there are at least two ways: via the Admin panel and using SQL query.

Via the Admin panel

The first method is via the Admin panel. In the Admin panel, click on Discussion under the Settings tab. Uncheck "Allow link notifications from other blogs (pingbacks and trackbacks.) "

[caption id="attachment_1407" align="alignnone" caption="Figure 1: Disable the trackbacks"]Figure 1: Disable the trackbacks[/caption]

Using SQL query

The second method is by using SQL query. If you have SSH access, you can run the SQL query below in the MySql client. Otherwise, you could use the phpMyAdmin tool, that is usually comes with cPanel, which is the most convenient way to manage the database.
UPDATE wp_options
SET option_value = 'closed'
wp_options.option_id =20
wp_options.blog_id =0;

[caption id="attachment_1417" align="alignnone" caption="Figure 2: Click on phpMyAdmin icon"]Figure 2: Click on phpMyAdmin icon[/caption]

To run the SQL query in phpMyAdmin, first, click on phpMyAdmin icon in cPanel, as shown in Figure 2. Once you are in phpMyAdmin, select your WordPress database, from the drop down menu on the left. The page will refresh and the database's tables will be displayed on it. Open the SQL tab (look at the top navigation bar), as shown in Figure 3. Paste the SQL query, and click Go. The database will be updated, and the trackbacks will be disabled.

[caption id="attachment_1418" align="alignnone" caption="Figure 3: The SQL tab"]Figure 3: The SQL tab[/caption]


I have shown you 2 ways to disable the trackbacks in this article. However, if you still need the trackbacks feature, you could use plugin like Akismet to help reduce the spam.

Friday, January 23, 2009

Host images in a subdomain

By default, most Web browser will create from two to four connections to the Web server, when downloading a Web page. This will results in slow Web page displaying, especially if the Web page contains more than one images. However, we can actually trick the Web browser, by hosting the image in other domain, such as Flickr or Picasa Web Albums. Therefore, the Web browser will download the images in parallel with the rest of the Web pages.

Suppose that you had, or subscribe to a lot of space and fast Web server. You can actually self host the images. The image will be hosted in a subdomain. For example, if your blog domain is http://yourdomain, the images could be served from http://images.yourdomain. Thus, this article will show you how to accomplished it.

Create the subdomain

In order to create the subdomain, you can use the cPanel or DirectAdmin, whichever you have, or via SSH, if you are a geek. Point the subdomain to the default WordPress uploads directory, which is /public_html/wp-content/uploads, provided that your WordPress installation is in /public_html directory.


Update WordPress Miscellaneous Settings

The next step is to instruct WordPress, where the upload files should be located. Go to the WordPress dashboard. Click on Miscellaneous under the Settings menu. Leave the first text box as is. By default, the second text box is empty. Fill it with the full URL path to files, which is


Now, whenever you upload new images, in a post, the new images will be uploaded into the new subdomain. Although, those images will actually will be located in the same directory as before, /public_html/wp-content/uploads.

Update MySql for all previous images

Up until now, you have successfully make WordPress to host images in a subdomain, but what about all the hundreds or thousands of images that you had posted previously. Fortunately, WordPress save the images information in the database, in pure text. Therefore, just use simple sql to change the images information, for example, from http://yourdomain/wp-content/uploads/2009/01/mypic.jpg to http://images.yourdomain/wp-content/uploads/2009/01/mypic.jpg.

Using phpMyAdmin in cPanel or DirectAdmin, or any other MySql client, connect to your WordPress database. Beforehand, remember to backup the database. That way, you will have a failsafe mechanism.

To update the images links the post contents, run this sql, after you have back up the database.
UPDATE `wp_posts` SET `post_content` = 
REPLACE( `post_content`, "http://yourdomain/wp-content/uploads/", 
"http://images.yourdomain/" )

To update the images links in the Media Library, run this sql. This step is not compulsory. Just to remind you that you should back up the database first.
UPDATE `wp_posts` SET `guid` = 
REPLACE( `guid`, "http://yourdomain/wp-content/uploads/", 

Redirect all the images links to the new sub domain

The last step, is to redirect all the previous posted images links to the new URLs. Duplicate links will make Google unhappy.

First, Back up your .htaccess file, which is located in public_html directory. Then, prepend a RedirectMatch code that will redirect all images to the new subdomain. This is one way to accomplished it.
RedirectMatch 301 ^/wp-content/uploads/(.*)$    http://images.yourdomain/$1

In conclusion, you have successfully trick the Web browser, by redirecting your images into a subdomain. Now, the Web browser will download images from you Web server in parallel. If you are using a cache plugin, please clean all the cache, as well as the Web browser's cache, in order to see the changes. Last but not least, please back up the database and the .htaccess file, before committing any changes.

Thursday, January 22, 2009

Two ways to hide the smiley face of Stats plugin Stats is one bang-up plugin, created by Automattic, besides Akismet. In order to use it, all we need is the API key. The rest is automatic. This plugin, which does not run on our server, will accumulate information on pageviews, popular posts and pages, where your traffic is coming from, and what people click on when they leave. The stats can be seen on the dashboard.

In order to collect the stats, the plugin will display an image of smiley face, which is usually located at the bottom of the page. However, if you don't like it, you can actually hide it. Actually, it is very easy. Just append this css code snippet into your theme style.css file.

As an alternative, you can append this Javascript code snippet into footer.php, after the wp_footer().
<script type="text/javascript">
var e = document.getElementById("wpstats"); = "0px"; "0px"; = "hidden";

Good luck.

Update: If you are too lazy to hack the CSS file, you can use the Stats Smiley Remover Plugin.

Thursday, January 1, 2009

How to create WordPress Archives page

To create an archives page for WordPress, you can use the Page Template feature. Here are the steps:

  1. Create an empty file—using your favourite text editor— in your theme folder, and name it archives.php, or whatever you like.

  2. Append these codes inside archives.php.
    /* Template Name: Archives */
    <?php get_header(); ?>
    <div id="archives">

    <h2>Archives by Month:</h2>
    <ul> <?php wp_get_archives('type=monthly'); ?> </ul>

    <h2>Archives by Subject:</h2>
    <ul> <?php wp_list_cats(); ?> </ul>


    <?php get_footer(); ?>

  3. Create a new page in WordPress, and name it Archives.
    Create new page

  4. Change the Template Attributes for Archives page, which is usually located at the right hand side of the Edit Page page,  to Archives (The name will depends on the template name).
    Change the page Template Attribute.

  5. Click on the Update Page button to save.

Now, you already have an archives page by month and by subject/category. By the way, you could also have the archives page to display some or all posts title, as discussed in this article.

List all titles of WordPress posts in one page

Using this code, you can list all titles of WordPress posts in one page. An example of usage is in an Archives page.

    global $post;
    $myposts = get_posts('numberposts=-1&offset=1');
    foreach($myposts as $post) :
    <a href="<?php the_permalink(); ?>">
    <?php the_title(); ?>
<?php endforeach; ?>

You can change it to n number of posts, by changing -1 in "numberposts=-1" to n.
For tutorial on how to create an Archives page, please read this article.

Wednesday, November 19, 2008

Wordpress 2.7 new update features

I had updated my WordPress version to WordPress 2.7-beta3-9750 from beta 1 via SVN.  Well, actually I had to do it by first updating the SVN version from my PC, zip it, upload it via FTP, and then extract it to my WordPress installation via cPanel. That's because of my Web hosting provider that does not support SSH.


By the way, that is not the purpose of this post. After upgrading, I headed to the admin Dashboard and click on the Update link located at the left nearly bottom. It says that I had the latest version of WordPress. That is as usual. However, I found that there are three new buttons: Re-install Automatically, Download and Hide this update. That is great, especially for the Re-install Automatically function. However, it is does not work yet. At least, by the time I wrote this post.

Those WordPress guys are working hard in order to make WordPress great software. Hopefully, the release of WordPress 2.7 would solve the problem of re-installing corrupted WordPress, for what ever reason.




Sunday, November 16, 2008

Thursday, November 6, 2008

Change WordPress displayed author name for all comments

Whenever you change the display name Users >> Your Profile >> Nickname, and set  the "Display name publicly as", it will only affect the newly posted comment by you. Actually, you can change the displayed author name for all comments.

You can change the displayed name of comment author for all comments using this sql statement:
UPDATE `wp_comments` SET `comment_author`='old-name'
WHERE `comment_author`=‘new-name’

Wednesday, November 5, 2008

How to create a WordPress theme option page

This tutorial will show you how to create a simple WordPress theme option page.

First, you will need a sample theme. Create a new folder in wp-contentthemes. Name it 'test' (or, whatever you like). Create three files in the 'test' folder: index.php, style.css and functions.php. Now, you should choose the 'test' theme as the current theme.

Second, open the functions.php file in your favourite text editor, and paste the following php code.
add_action('admin_menu', 'add_welcome_interface');
function add_welcome_interface()
/* add_theme_page( page_title, menu_title,
access_level/capability, file, [function]); */

add_theme_page('Your Theme Name', 'Your Theme Options',
'edit_themes', basename(__FILE__), 'editoptions');

function editoptions() {

<div class=“wrap">
<h2>Your Theme Name</h2>
<form action=“options.php" method=“post">

<?php wp_nonce_field('update-options'); ?>

<table class=“form-table">
<tr valign=“top">
<th scope=“row">First Option</th>
<td><input value=“<?php echo get_option('first_option'); ?>;"
<tr valign=“top">
<th scope=“row">Second Option</th>
<td><input value=<?php echo get_option('second_option'); ?>"

<input type=“hidden" value=“update" name=“action">
<input type="hidden" value="first_option,second_option"

<p class=“submit">
<input type=“submit" value=“<?php _e('Save Changes') ?>“


<?php } ?>

Finally, you can call the options that you save in index.php file, using the get_option() function.
echo get_option(‘first_option’);
echo get_option(’second_option’);

Function References:



Tuesday, October 21, 2008

Generate Wordpress theme online for free

These online Wordpress theme generators could be used to generate Wordpress theme, without the need of HTML, JS, PHP, or CSS knowledge. They are also very easy to use.
  1. Wordpress Layout Generator
  2. Wordpress Theme generator

Wordpress Version 2.7-almost-beta

The new look of Wordpress admin page. What do you feel. Isn't it great. I like it. If you disagree, please leave your comment.

Monday, October 20, 2008

Blog Editor Tools

Here is the list of blog editor tools.

  1. Windows Live Writer

  2. w.blogger

  3. Scribefire

  4. Qumana

  5. BlogJet

  6. BlogDesk

  7. Zoundry Raven

  8. Post2Blog

  9. ecto

  10. MarsEdit

If you don’t see an editor on the list that you can’t live without, please take a second and leave a comment about it.

Monday, August 18, 2008

9 ways to hide affiliate links

These codes are useful for hiding the affiliate links. However, please read the affiliate program terms of service, so that you won’t go against it.

For all except the last way (.htaccess redirect), create the respective file for each affiliate link with the code for the chosen redirect style. Replace ‘http://your-affiliate-link-goes-here’ with the URL of the affiliate link.

For example, if you choose to use the PHP redirect, first create a PHP file. Copy and paste the PHP redirect code into that file. Replace ‘http://your-affiliate-link-goes-here’ with the affiliate link URL.

Every time you want to link to the affiliate link, just link to that file.

You have to create new file for each affiliate link.

HTML redirect

<title>HTML Redirect</title>
<meta http-equiv="refresh" content="0;
Please wait. Redirecting...

PHP redirect

<?php header("Location: http://your-affiliate-link-goes-here"); ?>

ASP redirect

<%@ Language=VBScript %>
<% Response.AddHeader "Location","http://your-affiliate-link-goes-here" %>

ASP.NET redirect

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)

Coldfusion redirect

<.cfheader name="Location" value="http://your-affiliate-link-goes-here">

JSP redirect

<% response.setHeader( "Location", "http://your-affiliate-link-goes-here" );
response.setHeader( "Connection", "close" ); %>

cgi Perl redirect

$q = new CGI; print $q->redirect("http://your-affiliate-link-goes-here");

Ruby on Rails redirect

def old_action redirect_to "http://your-affiliate-link-goes-here" end

Apache .htaccess on Linux

Add this code to the end of .htaccess file. Replace ‘http://your-affiliate-link-goes-here’ with the affiliate link URL. To have more than one affiliate link, just add another RewriteRule.
RewriteEngine on RewriteRule ^affliate.php$
http://your-affiliate-link-goes-here [R]