Support » Plugin: Postie » [Plugin: Postie] Is there a way to post to Custom Post Types?

Viewing 15 replies - 1 through 15 (of 21 total)
  • anyone??

    @mstracylee, did you find a solution for this?


    No answer??

    I added Custom Post Type support to this plugin. You can grab a copy of the modified file (or the entire plugin) from my fork of Postie on GitHub.

    I have not added any UI to the plugin. Instead, you can specify the Custom Post Type in the Email Subject.

    To publish a post with a Custom Post Type, you simply prefix the email subject with the Custom Post Type name followed by the Custom Post Type delimiter.

    For example, if I have a Custom Post Type called ‘movies’ and I wanted the title of my post to be ‘My Favorite Movie’, I would send an email with the subject ‘Movies // My Favorite Movie’.

    Postie will then look for the Custom Post Type delimiter (which is ‘//’ by default, but this can be changed on line 161 of my modified postie-functions.php). If it finds the delimiter, it will then check if Custom Post Type ‘movies’ exists.

    If the Custom Post Type exists, it strips out the ‘Movies // ‘ part of the subject and publishes the post with Custom Post Type ‘movies’ and the post title as everything after ‘Movies // ‘.

    If the Custom Post Type is not found, or there is no delimiter found in the subject of the email, then the post will be published as post type ‘post’, i.e., the default post type (the default behavior in Postie).

    This modification works with the latest version of Postie (v1.4.4 as of this post), but I will be keeping my modified copy updated as new versions of Postie are released.

    I would really love if the plugin developer could include this feature in a future release of Postie. Until then, you can grab a copy of the modified file (or the entire plugin) from my fork of Postie on GitHub.

    this is already working in the current version of postie. please read the readme.txt..

    “= Category and tag handling =
    * If you put a category name in the subject with a : it will be used
    as the category for the post
    * If you put a category id number in the subject with a : it will
    be used as the category for the post
    * If you put the first part of a category name it will be posted in
    the first category that the system finds that matches – so if you put

    Subject: Gen: New News

    The system will post that in General.

    tested and working.. ..did i miss something?

    Hello Raam Dev,

    Thanks for you post. I’m using taxonomies and replaced the ‘postie-functions.php’ file you modified, but without success. Posts are sent to the default category that I specified in the Postie config options.

    Here is what I put in the Subject Line:

    “Durban // Test”

    hoping that the Post titled “Test” would appear “Durban”. I tried using the ‘tag_ID, which also didn’t work. Does your code recognize the tag_ID of the post?

    I’m using Postie Version 1.4.4

    Thanks. Bernhard

    El Puma, f4iedrich: Custom Post Types are not the same as Categories or Tags. Postie does not support changing the Post Type, which is what my modification does.



    @raam Dev – i’m trying out your fork for the CPT.. very nice work! Thank you for sharing it.

    The issue i’m having is that my CPT has a different taxonomy than the standard Categories and Tags taxonomies used for Posts — and used by Postie, Any thoughts on how to connect Postie to a different Taxonomy (specifically called “portfolio_categories”, in my case). Thanks!

    Raam Dev


    @tzeldin88: Thanks! Glad you’re finding it useful. 🙂

    I’m not sure about customizing Postie for taxonomies other than the standard Categories and Tags. I seem to recall, from the last time I looked at the Postie code, seeing several areas that relied on, or at least expected, the default taxonomies. However, you should be able to make it work. You’ll just need to poke around to find all the areas it assumes standard taxonomies.

    Good luck!

    Plugin Author Wayne Allen


    @raam Dev

    Any chance we can merge your fork into the main release?

    Raam Dev


    @wayne Allen

    Go for it! 🙂

    So is this integrated into postie now?

    Also, I would like postie to always post to a custom post type, by default, without putting anything in the subject line. Is this possible?

    I think I answered my own question. Using Raam’s code:

    if (in_array( $custom_post_type, $known_post_types )) {
    $post_type = $custom_post_type;
    } else {
    $post_type = 'post';
    } else {
    $post_type = 'post';

    Just make $post_type = 'messages';

    Or whatever the post type is.

    Although, actually, this doesn’t seem to work for me, in my modified version, or in Raam’s code. When I use the delimiter, my messages still post to regular posts, not the custom post type.

    The following is my edit in postie-functions.php. You’ll see where I added two additional comments describing where the default post types are set. You should be able to change those to do what you want.

     * Added by Raam Dev <>
     * Adds support for handling Custom Post Types by adding the
     * Custom Post Type name to the email subject separated by
     * $custom_post_type_delim, e.g. "Movies // My Favorite Movie"
    	$custom_post_type_delim = "//";
    	if (strpos($subject, $custom_post_type_delim) !== FALSE) {
    		// Captures the custom post type in the subject before $custom_post_type_delim
    		$separated_subject = explode($custom_post_type_delim, $subject);
    		$custom_post_type = $separated_subject[0];
    		$subject = $separated_subject[1];
    		$custom_post_type = trim(strtolower($custom_post_type));
    		// Check if custom post type exists, if not, set default post type of 'post'
    		$known_post_types = get_post_types();
    		if (in_array( $custom_post_type, $known_post_types )) {
    			$post_type = $custom_post_type;
    		} else {
    			// Default post type if the Custom Post Type specified in the subject doesn't exist
    			$post_type = 'post';
    	} else {
    			// Default post type if no delimiter is found in email subject
    			$post_type = 'post';
    /* --------- end by Raam Dev <> */
Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘[Plugin: Postie] Is there a way to post to Custom Post Types?’ is closed to new replies.