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.
Functions
The plugin contains these top level functions:
- printTitle
- Prints a title depending on WordPress’ conditional tags.
- printMetaKeywords4Post
- 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.
- getAllTags4Post
- Returns all tags for the given post. The tags are a combination of some default tags, the WordPress categories and WordPress tags.
- pringDescription4Post
- 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:
- getPostsAndPages
- Returns all published posts and pages with their
ID,guidandtitle. - getCategoriesForPost
- Returns all categories for the post with the given id.
- getTagsForPost
- Returns all tags for the post with the given id.
- getPostExcerpt
- Gets the excerpt for a post from the posts or post_meta table.
Finally, the class ChristiansPhpHelper contains these methods:
- combineArrays
- Returns an array as a combination of the given two arrays.
- string2array
- Converts a string to an array by splitting the string at a delimiter. This is a shortcut for
preg_split.
Leave a Reply