WordPress.org

Support

Support » Plugins and Hacks » Postie » [Resolved] Custom post type with two Custom Taxonomies

[Resolved] Custom post type with two Custom Taxonomies

  • Using Postie v1.5.15.

    I have a custom post type that has two Custom Taxonomies.

    Is it possible to get Postie to recognise the category/taxnomy using the default settings ie:

    [bbs] This is another title
    or
    tags:26 This is the title

    I cannot get this to work.

    If this does not work, is it going to be possible to do this with a filter using the v1.5.15 syntax – eg:

    add_filter('postie_post_before',...

    If so, could someone give a pointer to the best approach please?

    http://wordpress.org/plugins/postie/

Viewing 3 replies - 1 through 3 (of 3 total)
  • I managed to work out the following code that seems to work OK.

    I have two custom taxonomies – region and type.

    // Categories are specified in the subject using:  [category1] [category2] title - this is used for type
    // tags in the body using:  tag:tag1, tag2 - these are used for region
    
    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 );
    			unset($post[$post_part_to_check][$key]);
    		}
    	}
    }
    
    function add_custom_taxonomy_postie_post_function($post) {
    
    	// Check for categories and use in type
    	check_post_set_taxonomy($post,'post_category','type');
    
    	// Check for tags and use to set region
    	check_post_set_taxonomy($post,'tags_input','region');
    
    	return $post;
    }
    
    add_filter('postie_post_before', 'add_custom_taxonomy_postie_post_function');

    Is there a better way – improvements?

    Thanks

    Plugin Author Wayne Allen

    @wayneallen-1

    That looks good to me.

    Thanks for checking.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Custom post type with two Custom Taxonomies’ is closed to new replies.
Skip to toolbar