Shortcut Functions For Registering Taxonomies And Post Types In WordPress

After I had created several custom taxonomies and post types, adding more by directly calling the `register_taxonomy`[^1] and `register_post_type`[^2] functions seemed like a huge waste of space. The following functions create a shortcut for registering taxonomies and custom post types in WordPress; just choose whether you’d like the taxonomy to resemble Post Tags or Categories when calling the function `ucc_register_taxonomy`, and specify an array of taxonomies for `ucc_register_post_type`.

Continue reading “Shortcut Functions For Registering Taxonomies And Post Types In WordPress”

How To Filter FeedWordPress Posts Into Custom Post Types

I like to hang out on [COLOURlovers](http://www.colourlovers.com/) every so often and follow (previously called favorite) palettes and colors from the queue to add to my library of design inspiration. I use [FeedWordPress](http://feedwordpress.radgeek.com/) to scrape [my personal RSS feeds from ColourLOVERS](http://www.colourlovers.com/rss) into my WordPress blog as individual posts, and then use a custom filter to turn the ColourLOVERS syndicated posts into a palette (or color) shortcode that I can then style as I like.

Before the advent of [custom post types](http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress), I used categories and tags to sort out my palettes and colors from the rest of my posts. However, it now seems more logical to add these into a custom post type rather than jamming them into a post.

What follows is the filter I have in functions.php that cleans up the syndicated post, and then changes the post type as appropriate. You’ll want to make changes of your own, as I’m using custom functions to clean up the data and recreate the post as a shorttag, as well as adding custom taxonomy entries.

Continue reading “How To Filter FeedWordPress Posts Into Custom Post Types”

How to filter post titles

If you know that you will want to apply a filter to all of your post titles in WordPress, such as forcing uppercase, lowercase, or title capitalization, you can use a filter to do so. The filter below will force a title to lowercase as the post is saved:

[code lang=”php”]
if ( !function_exists( ‘ucc_post_title_filter’ ) ) :
function ucc_post_title_filter( $data ) {
$title = $data[‘post_title’];

$title = strtolower( $title );
$data[‘post_title’] = $title;

return( $data );
}
add_filter( ‘wp_insert_post_data’ , ‘ucc_post_title_filter’ );
endif;
[/code]

On line 5, strtolower() can be exchanged for any text-transforming function.