CPT-onomies Update: Version 1.2.1

Download CPT-onomies

CPT-onomies Screenshots

CPT-onomies Documentation

A new version of CPT-onomies has joined the ranks but don’t get too excited. It’s just a few bug fixes that have been brought to my attention since I released 1.2 back in December.

I hope you’re enjoying CPT-onomies and, as always, please let me know if you find any bugs, or have any feature requests, by posting to the CPT-onomies support forum.

Thanks for being such awesome users!

Posted in CPT-onomies, WordPress | Leave a comment

CPT-onomies Update: Version 1.2

Download CPT-onomies

CPT-onomies Screenshots

CPT-onomies Documentation

To say my life has been crazy the past 6 months would be a very large understatement but CPT-onomies 1.2 is finally here! On top of a few minor bug fixes, here’s what 1.2 brings to the table:

  • Create custom CPT-onomy archive pages with just a few simple lines of code!
  • Added the ability to set a CPT-onomy term description using ‘term_description’ or ‘{$taxonomy}_description’ filter’.
  • Non-public custom post types can now be used as CPT-onomies.
  • Exclude CPT-onomy terms from being listed in the “Assigning CPT-onomy Terms” admin meta box and, therefore, from being assigned to a post.
  • Added numerous filters, allowing you to:
    • Remove “Assigning CPT-onomy Terms” meta boxes from admin
    • Remove CPT-onomy dropdown filters from admin
    • Remove the CPT-onomy column and/or it’s sortability
    • Customize settings by removing options and setting default property values
  • I changed the cpt_onomy.php filename to cpt-onomy.php to match cpt-onomies.php (I’m not really sure why I gave it an underscore to begin with).
  • I, like many others, fixed the $wpdb->prepare() issue.
  • If you use the following CPT-onomy settings, be sure to re-save your settings to fix potential bugs:
    • Capability Type
    • Capabilities -> Read Private Posts

I hope you enjoy the update! And, like always, please let me know if you find any bugs. If you need me anytime soon, I’ll be the one drinking some damn scotch. Until next time, keep up the awesomeness!

Posted in CPT-onomies, Uncategorized, WordPress | Tagged , , , , , | Leave a comment

CPT-onomies Update: Version 1.1

Download CPT-onomies

CPT-onomies Screenshots

CPT-onomies Documentation

It took me long enough but the next version of CPT-onomies has finally shipped out! And, with it, some pretty cool new features:

  • Programmatically register your CPT-onomies
    • Much kudos and thanks to Travis Smith for the assist with this one!
  • When assigning CPT-onomy terms on the “edit post” page, choose from three different formats:
    • a checklist (same ole, same ole),
    • an autocomplete box (a pretty cool one, I might add),
    • and a select dropdown (for when you only want to select one term)
  • Customize the CPT-onomy archive page slug
    • Before, you were pretty much stuck with “{post type}/tax/{term slug}” (which is still the default) but now, via the settings panel, you can use your own keywords with a little help from the variables $post_type, $term_slug and $term_id. Don’t forget to flush/reset your rewrite rules once you’re finished!
  • Tell the CPT-onomy tag cloud widget whether you want the terms to link to their archive page or to their custom post type post page
  • When you’re using wp_get_object_terms() to request term information, you can now specify term ids to exclude from your results
  • The CPT-onomy class has a new function! Introducing get_term_ancestors(). I think it’s a little self-explanatory =)
  • CPT-onomies now supports Internationalization (can’t believe it took me so long!)
  • I also tweaked the UI and fixed a few bugs

I hope everyone enjoys the update as much as I do. Sorry it took me so long. My life has been a little crazy but I’m glad to be on the other side of the hiatus!

Please let me know if you have any questions or find any bugs! Thanks for being such awesome users!!

Posted in CPT-onomies, WordPress | Tagged , , , , , , , , , | 4 Comments

How to Define Reserve Slugs for WordPress Posts and Pages

This post was inspired by an answer I posted in the WordPress Stack Exchange.

This is an interesting WordPress problem that could span several scenarios. But let’s say you have a custom post type named ‘songs’ and you defined its slug as ‘songs’ so its archive page URL is http://www.mysite.com/songs.

This is fine and all but a slug used for a custom post type archive page, i.e. ‘songs’, is not saved in the database and is, therefore, not available when you’re creating/editing posts to tell WordPress “NO! The slug ‘songs’ is taken!”. With that said, a user could come along and create a post (or page) with the slug ‘songs’ which would therefore have the same URL as your custom post type archive page: http://www.mysite.com/songs.

So how do you keep users on your site from creating posts with particular slugs, a.k.a. reserve slugs?

It’s pretty simple, actually. Use one, or both, of the following two filters. They hook into WordPress when it’s checking a post’s slug, allowing you to return “true” which tells WordPress that the post slug is bad. If you return “true”, WordPress adds on a suffix, just like it would do if you were trying to use a slug that is already taken.

The first filter, ‘wp_unique_post_slug_is_bad_hierarchical_slug’, is for hierarchical posts and the second filter, ‘wp_unique_post_slug_is_bad_flat_slug’, is for non-hierarchical posts. While both filters provide the post’s $slug and $post_type, the hierarchical filter also provides the ID for the post parent so if the $post_parent is 0, you know this is a “base” post.

add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', 'rachel_carden_is_bad_hierarchical_slug', 10, 4 );
function rachel_carden_is_bad_hierarchical_slug( $is_bad_hierarchical_slug, $slug, $post_type, $post_parent ) {
   // This post has no parent and is a "base" post
   if ( !$post_parent && $slug == 'songs' )
      return true;
   return $is_bad_hierarchical_slug;
}

add_filter( 'wp_unique_post_slug_is_bad_flat_slug', 'rachel_carden_is_bad_flat_slug', 10, 3 );
function rachel_carden_is_bad_flat_slug( $is_bad_flat_slug, $slug, $post_type ) {
   if ( $slug == 'songs' )
      return true;
   return $is_bad_flat_slug;
}

These filters can be found in the WordPress function wp_unique_post_slug() in the wp-includes/post.php file.

Posted in Tutorial, WordPress | Tagged , | Leave a comment

CPT-onomies Documentation is Up and Running

Download CPT-onomies

CPT-onomies Screenshots

CPT-onomies Documentation

CPT-onomies is a WordPress plugin that allows you to create, and use, taxonomies powered by your custom post types, using the post titles as the taxonomy terms. The best part about CPT-onomies is that they work just like regular taxonomies and therefore use the same functions!

Unfortunately, not every taxonomy function works right now but don’t worry, I’ve created CPT-onomy functions to help bridge the gap between WordPress and the plugin. The CPT-onomy functions even mirror the WordPress functions, using the same parameters and return values.

Use the CPT-onomies Documentation to see which WordPress taxonomy functions work and when you’ll need to use a CPT-onomy function. The documentation also includes function parameters, return values, examples, and other helpful information.

If you notice a mistake, or have a function request, feel free to leave a comment or contact me.

Posted in CPT-onomies, WordPress | Tagged , , , | Leave a comment

CPT-onomies: Using Custom Post Types as Taxonomies

If you’ve ever used a WordPress custom post type or taxonomy, you know that they can be powerful tools for creating and organizing content. But what if I told you that you could take these features a step further and create relationships between your post types, using your post titles to assign taxonomy relationships?

Introducing “CPT-onomies: Using Custom Post Types as Taxonomies“:

Humble beginnings

When I was first building http://eng.ua.edu, I knew that custom post types would play a huge role (and basically take over my life). With numerous post types, I wanted to establish a dynamic “People” directory that would connect each person to the “Departments” they worked for, the “Buildings” they worked in, the “Capstone Engineers” they were featured in (our research magazine), and any other content available.

In came custom taxonomies. I created taxonomies that “mirrored” each custom post type (using the post title as terms) and, voila, a dynamic and easily filtered people directory was born! But while managing the “Buildings” taxonomy was easy (buildings don’t exactly come and go on a daily basis), imagine managing a list of 200+ people and having to make sure the “People” taxonomy always matched the “People” custom post type. It’s more than just managing the titles, you have to make sure the slugs match too! Let’s just say that system didn’t last long.

From Idea to Plugin

While the premise of being able to use custom post types as taxonomies, and not having to duplicate information, was always the root of the project, “CPT-onomies” has taken several forms. At first, it wasn’t even a plugin, it was in my theme. When it progressed to a plugin, it was just for personal use and was very rough around the edges, using all kinds of WordPress hacks in a devil-may-care manner. To give me some credit, I had only been using WordPress for a few months and was on a strict redesign schedule. “Behind the scenes” was not a high priority.

But the website launched, my WordPress skills grew, and before I knew it I was saying things like “I bet I’m not the only one who could use this setup” and “This system of using custom post types as taxonomies would make a great plugin”. Little did I know how much fun I would have over the next few weeks.

Developing CPT-onomies

It wasn’t until I started development that I came up with the idea to hook into WordPress core and register the custom post type taxonomies as actual taxonomies. Once this decision was made, the project grew tenfold but, boy, was it worth it. Not only did it make the plugin stronger but it kept the user from having to learn or implement new code. That, in itself, was worth every minute of development. Tack on an extensive custom post type manager, so the user can manage their custom post types within the admin, and you’ve got yourself a pretty powerful plugin. Is CPT-onomy an official WordPress term? No. It’s just a fun word I made up. =)

Using CPT-onomies

One of the best features of the CPT-onomies plugin is that you don’t have to create CPT-onomies to put the plugin to good use. Featuring a full-fledged interface, CPT-onomies allows you to create custom post types, and manage them, without touching one line of code! If you’re already using a plugin, or theme, that creates custom post types, don’t worry, CPT-onomies is all-inclusive. Any registered custom post type can be used as a CPT-onomy.

Learn more about CPT-onomies or download CPT-onomies. Refer to the plugin’s support forums or my CPT-onomies section if you ever need any help. If you can’t find what you need, or come across any bugs, please let me know.

I hope you enjoy using CPT-onomies as much as I enjoyed bringing it to life.

Posted in CPT-onomies, WordPress | Tagged , , | Leave a comment

Hi there

My name is Rachel Carden and I’m a High Ed Web Developer from the GREAT state of Alabama who loves working with WordPress, solving puzzles, watching college football and just about anything related to Disney.

But, while I may tweet about all that stuff, RachelCarden.com will be a place to share my work, thoughts and ideas surrounding WordPress and my love for programming, problem solving, and the World Wide Web.

So make yourself at home. Learn more about my background, or follow me on Twitter, and take this little nugget of inspiration with you: “All our dreams can come true, if we have the courage to pursue them.” – Walt Disney

Posted in Personal | Leave a comment