Nov 12 2008

WordPress Categories and Tags

Category: SoftwareTeknovis @ 20:56

There seems to be differing opinions on how Categories and Tags should be used within WordPress. So now that I some experience with both of these I have decided to go with the following principles:

  • I am using Categories as very high-level descriptors, like chapters in a book.
  • I am using Tags as precise pointers, like the index in a book.

Consequently, the number of Tags is likely to grow very large, and it is likely that a substantial number of these Tags will only be used once. So I will keep this under review.

The Tag Cloud shows a maximum of 45 Tags by default, as described in the wp_tag_cloud() documentation. However, this can easily be increased to any maximum number using a parameter.

I had expected that I could parametrise wp_tag_cloud() as part of my theme, but I could not find any way to do this!

Instead I had to modify one of the WordPress PHP files. There appeared to be two approaches:

I am not sure what the relative advantages and disadvantages of these approaches are, but I chose the second one.

Tags: ,

Nov 12 2008

Fun with htaccess

Category: SoftwareTeknovis @ 17:50

I have now started using pretty URLs for my permalinks. This took me a long time to get working, but I have to admit that this was my own fault :o

Configuring permalinks within WordPress is straight-forward, and it is described in Using Permalinks.

My problems occurred because WordPress could not create the required .htaccess file due to the way that Blacknight has installed WordPress in a different directory to the one that appears in the URL.

In trying to solve my problems, I learned a lot about .htaccess files! I thought that these Stupid htaccess Tricks were very useful.

Everything appears to be working perfectly now, but there is still one thing that I do not understand. My .htaccess file contains the following three lines:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

There are many pages, such as htaccess rewrite code explanation, that describe these three lines. It is the explanation for the third line that confuses me:

Rewrites any request with 1 or more characters to /index.php, which launches wordpress and handles all redirections and what to display.

Firstly, the RewriteRule documentation states that the matched pattern is replaced with the substitution string. Furthermore, the Regular Expression documentation states that the period will match any single character! So what exactly is happening here?

Secondly, how does it rewrite the request to /index.php? Is it appended to the URL, or is it sent as a POST variable?

Tags: , , ,