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

Monday, July 14, 2008

Nuffnang down time

This morning, Nuffnang server seems to be down.

[caption id="attachment_260" align="alignnone" caption="Top banner"]Top banner[/caption]

[function.mysql-connect] =

[caption id="attachment_261" align="alignnone" caption="Between post"]Between post[/caption]

Friday, July 11, 2008

Wordpress: Display posts by categories

This function could be used to display all categories and their posts. One example of its usage is for the Archive page.

To use it copy and paste the function into the file "functions.php" located inside the "wp-contentthemesyour theme" folder. You may have to create that file if it does not exist yet.

To call the function, use posts_by_cats(3), where 3 is the number of post to be displayed in each category.
/* This funtion will display posts for each parent categories */
function posts_by_cats($num_of_posts) {
global $wpdb;
// query the cat id
// remove `parent` = 0 to display all categories
$sql = "SELECT `term_id` FROM $wpdb->term_taxonomy WHERE
`taxonomy`='category' AND `parent` = 0 AND `count` != 0";
$cats = $wpdb->get_results($sql, ARRAY_A);
//display posts for each cat
foreach ($cats as $cat) {
$cat_id = $cat['term_id'];
// query the cat name
$sql = sprintf("SELECT `name` FROM $wpdb->terms
WHERE `term_id`=%d", $cat_id);
$cat_name = $wpdb->get_var($sql); echo '';
echo '<h3><a href="'. get_category_link($cat_id)
. '">' . $cat_name . '</a></h3>';
// query all the posts for each cat
query_posts(sprintf("cat=%d&amp;showposts=%d", $cat_id, $num_of_posts));
// the loop
if (have_posts()) :
echo " <ul>";
while(have_posts()) : the_post(); ?>
<li><a title="<?php the_title_attribute(); ?>"
href="<?php the_permalink() ?>"
rel="bookmark"><?php the_title(); ?></a>
<?php endwhile;
echo '<li><a href="'. get_category_link($cat_id)
. '">(more)</a></li>';
echo "</ul>"; endif; echo " "; } } ?>
</li> </ul>

Thursday, July 3, 2008

Wordpress 2.6 beta 2 problem

Yesterday, Ryan Boren had announced the release of Wordpress 2.6 beta 2.

The only thing that I am disappointed with was the “ Stats” plugin. The vertical bar for the login page, of the stat, at the dashboard, was missing. At least for Firefox 3. I have to use the tab key to fill in the login information.

Download Wordpress 2.6 beta 2

Thursday, June 26, 2008

Best feature of Wordpress 2.6

WordPress is in its beta stage 1 of version 2.6 right now.


One of the new feature that I like is the theme previewer. With this feature, we can preview a theme live, before actually activating it.

Hence, we no more need an offline test server for testing new theme, before using it.


WordPress For Dummies

Wednesday, June 25, 2008

Nuffnang vs Advertlets at random

This tutorial will show on how to make Nuffnang and Advertlets ads to display at random (not at the same time on each page).

First you need to put this code in the header.php file.
global $x;
$x = rand(1,2);
This code will generate a random number of 1 and 2, and then substitutes it to the global variable x.

Next, insert the nuffnang and advertlets inside the code below.
if ($GLOBALS['x'] == 1) { ?>
<!--nuffnang--> <?php } else {?>
<!--advertlets--> <?php } ?>
Now, just copy the code and paste it into the template, as many as desired.

The code will show one or more nuffnang or advertlets ads at random with a chances of 50%.

Monday, June 23, 2008

Who digg your article

Ever wonder who digg your submitted articles to

You can easily check it within seconds with this site:

What you need is your username. No password is needed.

Saturday, June 14, 2008

Create a Rotating Ads

If you run more than one ads, but lack of space to put the ads, you can actually rotate the ads.

The code below will create a random number from 1 to 10. Since I want both ads to be shown with a probability of 50%, I put the condition if (x > 5). However, you can change this number.

<?php $x = rand(1,10); ?>
<?php if ($x > 5) { ?>

<!--your first ad code-->

<?php } else {?>

<!--your second ad code-->

<?php } ?>
You can read more about PHP rand() function here.

Thursday, June 5, 2008

Give Error 404 to your plugins folder

It is crucial to hide your WordPress plugins folder. Click here for the reason why.

This is one way to do it.

Create a ".htaccess" file in the root of the WordPress installation.

Inside that file put this line of code:
Options All -Indexes

The idea is very simple. This instruction set will order Apache to not display list of files or directories, if there is no index file exists.

However, make sure not to touch anything else inside your ".htaccess" file.

Backup that file first. Even a small mistake will give your blog a "Server Error 500". If that ever happen, just restore the original ".htaccess" file.

Wednesday, June 4, 2008

I know what plugins you are running

If you run a Wordpress based blog, try something like this:

(replace "yourdomain" with your blog domain name)


Did you see what I see. Everybody can see what plugins you are running.

You can also Google for the name of some of the famous plugins. Google will display many open Wordpress based blog plugins directory.

So what is wrong if others can see them?

Usually you will use some third party plugins. Most of use did right? Either we are too lazy to write our own plugin, or we just don't know how to.

That is the problem. You don't know how secure the plugins that you are using. Maybe there is some bug found, but you are to lazy to update it to the recent version.

Hence, exposing the plugins that you are running may exposed you to some attack.

As a conclusion, hide the plugins folder.

Tuesday, May 20, 2008

Display Maths with Wordpress

Displaying Mathematics notation in a browser is not an easy task. One option is by using a plugin such as Design Science MathPlayer™, which enables Microsoft Internet Explorer to display mathematical notation in Web pages. However, the plugin is not so popular, and it does not comes with the browser by default.

Another way to do it is by using a public LaTeX server, using standard LaTeX code. An example of a public LaTeX server is As an example,{-infty }^{infty }e^{-x^{2}};dx=sqrt{pi }&bg=fff&s=2.

One way to use it is by using the img tag of HTML.

For example,
<img src=" int_{-infty}^{infty}e^{-x^{2}};dx=sqrt{pi }&bg=fff&s=2" alt="" />
will produce this image.

Please note that adding bg=fff would produce an image with white background (default is black). As an addition, s=2 is for the size.

However, it is a messy and error prone job to do it this way.

Fortunately, there is an alternative, for Wordpress user. A PhD student at Center for Advanced Study and Institute for Theoretical Computer Science, Tsinghua University, Zhiqiang Zhang had created a plugin for Wordpress, called Latex for Wordpress. This plugin uses LaTeX code to generate images. Although the plugin uses the Wordpress public LaTeX server, a local LaTeX service such as MimeTex is preferable, in case the public server is down. Some Web hosting support MimeTeX by default.

With this plugin, adding Maths notation is as easy as adding the LaTeX code. For example, for displaying an inline math equation, use
$$int_{-infty }^{infty }e^{-x^{2}};dx=sqrt{pi }!$$
and, for the math mode, use
$$!int_{-infty }^{infty }e^{-x^{2}};dx=sqrt{pi }!$$
Notice that there is an exclamation mark "!", just after the second dollar sign.

Download Link:

Update: You can also try the new Easy LaTeX plugin by Manoj.

Note: If you have trouble in writing the LaTeX code, use TeXaide.

Friday, April 25, 2008

How to backup WordPress data

Backup is a process of duplicating data, so that it could be used to restore the original after a data loss event. This tutorial will show how to backup your WordPress posts, pages, comments, custom fields, categories, and tags easily, using WordPress eXtended RSS (WXR).

To backup:

Step 1: Login to your WordPress Control Panel.
Step 2: Click on Manage.
Step 3: Click on Export
Step 4: Click on "Download Export File" button.

You will download the WXR file, for example "wordpress.2008-04-24.xml". 2008-04-24 is the date of the WXR file downloading.

To restore:

Step 1: Login to your WordPress Control Panel.
Step 2: Click on Manage.
Step 3: Click on import.
Step 4: Scroll down to the end of the Import list.
Step 5: Click on Wordpress.
Step 6: Click on the Browse button, and choose the WXR file.
Step 7: Specify the author. Click on "Download and import file attachments", if necessary.
Step 8: Click on the Submit button.

note: The maximum WXR size that can be imported, may vary, depends on the PHP settings.

Tuesday, April 22, 2008

Wordpress xmlrpc.php error

A Weblog Client is a desktop software that you can use to post to your Wordpress blog from your PC without the use of Web browser, via xmlrpc.php. By using a Weblog client, you are able to write posts offline and save drafts. However, some Web hosting provider block the access to xmlrpc.php, due to some security issues, at least for an older version of Wordpress.

To solve this problem, enter the following code inside your .htaccess file:
<files xmlrpc.php>
SecFilterInheritance Off

This code will instruct the Apache server to exclude xmlrpc.php file from the security filter check.

note: Don’t forget that the line ending of the .htaccess file is of type Unix (LF) before submitting it to your server, if it is a *nix based server. Otherwise, you are going to get Server Error 500.

Wednesday, April 16, 2008

Check your blog load time

This tool could be used to determine a blog load time.

Enter your domain name in the text box, for example

Tuesday, April 1, 2008

Ping your blog to technorati

To automatically ping Technorati, whenever you submit new post, enter the following URI in your blog configuration:

For example, if you are using WordPress, go to Settings > Writing, scroll down to Update Services section, and enter the URI.