Christian’s WordPress Utils

Since I’m a passionate user and plugin developer of WordPress I hacked together a plugin with some utility methods that I was using all over the place.

You can download the plugin as tar or zip file. Then copy it to the wp-content/plugins directory and activate it on the Plugins screen. Now you can use the following functions.


The plugin contains these top level functions:

Prints a title depending on WordPress’ conditional tags.
Prints keywords that can be used inside a meta tag consisting of the categories and tags for the specified post or page. You can add an array with keywords that should be ignored.
Returns all tags for the given post. The tags are a combination of some default tags, the WordPress categories and WordPress tags.
Prints the tagline of this blog. If there’s an excerpt for the current post or page we’ll use it as a description.

The class ChristiansWordPressHelper contains these methods:

Returns all published posts and pages with their ID, guid and title.
Returns all categories for the post with the given id.
Returns all tags for the post with the given id.
Gets the excerpt for a post from the posts or post_meta table.

Finally, the class ChristiansPhpHelper contains these methods:

Returns an array as a combination of the given two arrays.
Converts a string to an array by splitting the string at a delimiter. This is a shortcut for preg_split.