WordPress: Get IDs of *ALL* post tags

WordPress contains a function for getting the tags associated with a post (get_the_tags) but none for retrieving the IDs of all site wide available tags.

The solution to this problem is quite easy if you remember that post tags are nothing else but pre-defined taxonomies and that you can use the function get_terms to retrieve the terms of a taxonomy:

Funny enough there is a function for getting all category IDs (get_all_category_ids).

Yet another rant about bad WordPress plugin programming habits

The other day I came across a plugin that provided some useful functions to WordPress but is so badly coded that I can’t recommend it to anyone to use it. Though there are a lot of blog posts ranting about people “doing it wrong” this not be named plugin does so many things wrong in one place that I’m simply feeling the urge to write about a few of them.
Continue reading Yet another rant about bad WordPress plugin programming habits

The selectbox mystery of WordPress

The other day I wanted to use a selectbox with 5 elements in my plugin’s option page. No problem I thought:

What everybody including me expects is something like this:

But I actually got this:

The mystery lies in the style sheet for the admin area:

This forces every selectbox to display only one element. I have no idea why this is implemented. There is also a ticket in the WP tracking system discussing this behaviour since two years.

The solution to this problem is quite easy:

Seems easy but costed me over 1 hour of my lifetime.

WordPress: Shorten title

A frequently asked question in WordPress forum is how to shorten the title of a post to a predefined number of characters and to append a “…”.

The problem is solved with a few lines of code:

The variable $chars has to be set to the number of characters you want to have in your title and in line 6 you have to define the text to replace the omitted part of the title (… is the typographically correct version of three points, called ellipse).

It’s a bit disadvantageous that the title could be cut in the middle of a word. If you like you can extend the function accordingly:

If you copy the function into the file functions.php of your theme all calls of the_title will return the shortened title.

Remove “by author” post section from Genesis themes

As I already wrote in How-to remove the author from your Twenty-Ten posts most blogs do not need the section “by author” since there is only one author.
By default most Genesis themes contain this section (e.g. the prose theme):

Let’s see how-to remove the author’s name from the post info. Continue reading Remove “by author” post section from Genesis themes

WordPress: Remove links from the_category()

The standard way to display the categories a post belongs to is to use the function the_category, e.g, the call the_category(', '); will output:

link, photo, regular, video

As you see the categories are automatically linked to their respective category pages which in most cases is the style needed. Nevertheless there may be situations where you (or your customer) does not want the categories to link anywhere. Unfortunately WordPress does not provide any straightforward method to accomplish this so we have to make a small detour.

There are two ways we can take: rebuild the output or filter the output. Continue reading WordPress: Remove links from the_category()

WordPress plugins: Don’t hard code path names …almost never!

The other day I found a plugin claiming the following in its instructions:

What the heck? Why shouldn’t I change the name of the folder? The author didn’t actually hard code the plugin path of the plugin, did he? Continue reading WordPress plugins: Don’t hard code path names …almost never!

WordPress: Unified Login Error Messages

If you log-in to your WordPress blog and use an unregistered username the system will answer “ERROR: Invalid username. Lost your password?” and if you got your username right but not your password: “ERROR: The password you entered for the username admin is incorrect. Lost your password?”
So you know independently if you used a registered username or if the password isn’t right. That’s nice of WordPress, isn’t it? From the user point of view sure it is … and from the view of a possible attacker, too! Continue reading WordPress: Unified Login Error Messages

How-to remove the author from your Twenty-Ten posts

There are more than 1300 themes available in the official Theme Directory but many WordPress blogs are using the default theme Twenty Ten. The default header of a post looks like this:

Besides the date of publications the author of the article is displayed but since most blogs are operated by single persons this information is totally unnecessary. Additionally many bloggers write their posting while they’re logged in as Administrator so that the author is displayed has “admin”. This is not only unnecessary but also looks like you can’t handle your blog correctly.
Continue reading How-to remove the author from your Twenty-Ten posts

WordPress: Disable plugin table paging

Since WordPress 3.0 the plugin table is paginated by default, 20 entries at a time. In my mind this is totally useless since it means that I have to click through my plugins instead of simply scrolling through them with the mouse wheel. But there’s a more or less “hidden” option to display all plugins at once.
Continue reading WordPress: Disable plugin table paging