New WordPress Plugin: Post Type Icons

WordPress’ announcement of the dashboard redesign inspired me to overhaul the way icons are done in SuperCPT (note: this addition will come in version 0.2, but you can use it now by cloning it from GitHub). After doing so, I realized I could easily parse the icon piece out as its own plugin! Enter Post Type Icons.

Post Type Icons is a radically simple plugin that gives you 361 wonderful icons courtesy of Font Awesome. The icons are font-based, so they’re vector in nature and look amazing no matter your screen’s DPI. Now your custom post types can have custom icons that look just like the core icons in every state (previously, it was difficult to get the hover/active state working quite right). This will be in the WordPress Plugin Repository as soon as it’s approved!

Instructions for use

  1. Install and activate the plugin as usual.
  2. Go to Tools → Post Type Icons and figure out which icon you want to use. Get the name from underneath it.
  3. In your theme or plugin, add the following bit of code (replacing “my-post-type” and “icon-name” as appropriate):
    pti_set_post_type_icon( 'my-post-type', 'icon-name' );

    For example:

    pti_set_post_type_icon( 'event', 'calendar' );

Here’s what that looks like in a normal and active state:

Post Type Icons demo: normal state Post Type Icons demo: active state

  1. (alternate) Instead of calling the function pti_set_post_type_icon() you can use the global variable $pti_icons. This way you don’t have to check if the function exists, or risk a Fatal error. Simply declare $pti_icons an associative array with key => value pairs of post type => icon name. Here’s our event/calendar example again using the global variable:
    $GLOBALS['pti_icons'] = array( 'event' => 'calendar' );

I hope you enjoy this plugin! At some point (hopefully on the sooner side) I’ll make a GUI for this. I also set it up to potentially allow many icon sets, so I’ll add more to the collection. What would you like to see in it?

6 thoughts on “New WordPress Plugin: Post Type Icons

  1. Hi,
    I’ve updated to 0.21 your WP plugin and it does not work properly any more 🙁

    If I want to set 2 icons to 2 custom posts, only the last one is displayed.

    Example:
    $GLOBALS[‘pti_icons’] = array( ‘members’ => ‘group’, ‘goals’ => ‘flag-checkered’);

    only ‘goals’ is correctly displayed

  2. Hi, me again, tried to add a 3rd icon but it works only if 1. debug display=on + any warning appears! Otherwise the 3rd icon of the custom post does not appear…

    register_post_type( ‘HPPush’,
    array(
    ‘labels’ => array(
    ‘name’ => __( ‘Home page push’ ),
    ‘singular_name’ => __( ‘Push’ ),
    ‘add_new_item’ => ‘Add New’,
    ‘edit_item’ => ‘Edit’,
    ‘new_item’ => ‘New push’,
    ‘all_items’ => ‘All pushes’,
    ‘view_item’ => ‘View this page’,
    ‘search_items’ => ‘Search’
    ),
    ‘menu_position’ => 2,
    ‘public’ => true,
    ‘has_archive’ => false,
    ‘supports’ => array(‘title’, ‘excerpt’, ‘revisions’),
    ‘rewrite’ => array( ‘slug’ => ‘pushes’,’with_front’ => false),
    )
    );

    $GLOBALS[‘pti_icons’] = array(‘HPPush’ =>’bell’, ‘members’ => ‘group’, ‘formationsarc’ => ‘flag-checkered’);

  3. Hi. I love your plugin. I just wonder how to change the icon for (default) posts?
    I’ve tried the below in my functions.php file:

    pti_set_post_type_icon( ‘post’, ‘square’ );

    but I wasn’t successful. However, I was with other CPT but not with the common ‘post’.
    Any idea?
    I look forward instructions 🙂
    Regards

Leave a Reply