Support » Plugin: Postie » Support for custom taxonomy in subject line?

  • Resolved cfink381


    I’m considering adding a custom taxonomy or two to my site, but I don’t want to break my existing workflow with Postie. Does Postie support the setting of custom taxonomies in the subject line?

    For example, my site deals with books and each post has a category for “age group” (Children’s, Middle Grade, Young Adult, etc.) and a category for “genre” (Mystery, Thriller, Sci-Fi, etc.). Right now these are both set as categories, and I’m sending them in with a subject line like:

    [Young Adult] [Sci-Fi] Awesome Book by Joe Author

    This setup works great. But I’d like to expand my users’ ability to search for books, and setting up a new taxonomy of “age group” and “genre” seems to make sense. So I’d love to be able to send in a subject line like:

    [Age Group: Young Adult] [Genre: Sci-Fi] Awesome Book by Joe Author]

    Is this possible?

    Thank you!

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Wayne Allen


    Postie will recognize any term in the WordPress taxonomy, however, you can’t restrict it like your example.

    Postie will match the terms against any taxonomy and there isn’t an guarantee which will be used if you have duplicates. I.e. category sci-fi and genre sci-fi.

    Excellent! Thanks for the quick response. I’ll move forward by creating the custom taxonomies and making sure there are no duplicates between them and the categories. Thank you!

    Just ran a few tests through and Postie is correctly picking up the IDs for the custom taxonomies (which I can see in the debug output), but they’re not being applied to the post.

    The end of the debug output shows:

    Post Author: 1
    Date: 2014-01-27 17:00:00
    Category: 10
    Category: 15
    Category: 6

    ID 10 is Fiction in the Genre taxonomy
    ID 15 is Sci-Fi in the Genre taxonomy
    ID 6 is Young Adult in the Age Group taxonomy

    All these are correct, based on my subject line:
    [Fiction] [Sci-Fi] [Young Adult] Awesome Book by Joe Author

    Is Postie trying to apply the IDs as taxonomy = category, and therefore not applying them correctly since the IDs relate to taxonomies other than category? Any recommendations on how to set the taxes correctly?

    Thank you!

    Plugin Author Wayne Allen


    I’ll need to look into this a bit more. I’ve done this exact thing in the past, but maybe WordPress 3.9 is more picky.

    Plugin Author Wayne Allen


    Just to make sure we’re looking at the same thing, how did you create the taxonomy? Did you use a plugin?

    I used Themergency’s code generator ( and pasted the code in my theme’s functions.php file. I used all the default values except for setting rewrite to false.

    Thanks for looking in to this!

    Plugin Author Wayne Allen


    Postie will only choose a taxonomy if you have “Match short category” set to yes.

    Just ran some more tests through and I’m still getting the same result: Postie is identifying the correct custom taxonomy IDs, but they are not being applied to the post.

    I’ve updated WordPress to 3.9.1, deactivated, removed and reinstalled the latest version of Postie and deactivated all other plugins. “Match short category” is set to Yes.

    Here’s the section of the debug output where Postie is identifying the categories via the wildcard:

    tag_Categories: found categories
        [0] => Array
                [0] => Array
                        [0] => [Fiction]
                        [1] => [Action and Adventure]
                        [2] => [Everything else]
                        [3] => [Image and Text]
                [1] => Array
                        [0] => Fiction
                        [1] => Action and Adventure
                        [2] => Everything else
                        [3] => Image and Text
    lookup_category: Fiction
    category: found by name Fiction
    stdClass Object
        [term_id] => 10
        [name] => Fiction
        [slug] => fiction
        [term_group] => 0
        [term_taxonomy_id] => 31
        [taxonomy] => category
        [description] =>
        [parent] => 0
        [count] => 0
        [filter] => raw
    lookup_category: Action and Adventure
    category wildcard lookup: Action and Adventure
    category wildcard found: 12
    lookup_category: Everything else
    category wildcard lookup: Everything else
    category wildcard found: 9
    lookup_category: Image and Text
    category wildcard lookup: Image and Text
    category wildcard found: 23

    “Fiction” is the only Category, “Action and Adventure” is the Genre taxonomy; “Everything else” is the Age Group taxonomy, and “Image and Text” is the Style taxonomy. The “Fiction” category is successfully applied to the post, but the others are not.

    Any thoughts on how to fix? Do I need a custom filter?

    Thank you!

    Plugin Author Wayne Allen


    Odd that it is not working for you. When I test it the custom taxonomies are applied.

    You could write a Postie AddOn to specifically update the taxonomy.


    Not sure why the custom taxonomies weren’t working for me, but I was able to get it working with a Postie AddOn, as recommended. Thank you!

    Plugin Author Wayne Allen


    Thanks for the update.

    @cfink381, Any way you could post a code sample with your solution? I’m trying to accomplish the same thing, but I’m kind of stuck. Thanks!

    @jenkma02: Sure thing!

    	Add code set custom taxonomies to the post
    	function check_post_set_taxonomy($post,$post_part_to_check,$taxonomy_name) {
    			foreach ($post[$post_part_to_check] as $key=>$cat_or_tag) {
    			if (term_exists($cat_or_tag, $taxonomy_name)) {
    				wp_set_object_terms( $post['ID'], $cat_or_tag, $taxonomy_name, true );
    	function add_custom_taxonomy_to_post($post) {
    		// Check for categories and use in type
    		return $post;
    	add_filter('postie_post_before', 'add_custom_taxonomy_to_post');
    	End code set custom taxonomies to the post

    Just replace taxonomy1, taxonomy2, taxonomy3 & taxonomy4 with your taxonomy names and it should work.

    Hope this helps!

    Forgot to mention that the code above is the contents of filterPostie.php. Details here:

    Awesome, thanks so much!!!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Support for custom taxonomy in subject line?’ is closed to new replies.