WordPress.org

Ready to get started?Download WordPress

Forums

Postie
Is there a way to post to Custom Post Types? (22 posts)

  1. mstracylee
    Member
    Posted 2 years ago #

    I am looking to be able to use postie to update to custom post types. I am pretty sure it doesn't have this capability as of yet. Is there a way to change something to make it happen?

    Thank you in advance!

    Tracy Lee

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

  2. mstracylee
    Member
    Posted 2 years ago #

    anyone??

  3. Arnii
    Member
    Posted 2 years ago #

    @mstracylee, did you find a solution for this?

    Thanks.

  4. Cristiano
    Member
    Posted 1 year ago #

    No answer??

  5. Raam Dev
    Member
    Posted 1 year ago #

    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.

  6. El Puma
    Member
    Posted 1 year ago #

    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?

  7. f4iedrich
    Member
    Posted 1 year ago #

    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

  8. Raam Dev
    Member
    Posted 1 year ago #

    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.

  9. tzeldin88
    Member
    Posted 1 year ago #

    @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!

  10. Raam Dev
    Member
    Posted 1 year ago #

    @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!

  11. Wayne Allen
    Member
    Plugin Author

    Posted 1 year ago #

    @Raam Dev

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

  12. Raam Dev
    Member
    Posted 1 year ago #

    @Wayne Allen

    Go for it! :)

  13. publicradio
    Member
    Posted 1 year ago #

    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?

  14. publicradio
    Member
    Posted 1 year ago #

    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.

  15. publicradio
    Member
    Posted 1 year ago #

    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.

  16. Raam Dev
    Member
    Posted 1 year ago #

    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 <raam@raamdev.com>
     * 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 <raam@raamdev.com> */
  17. Wayne Allen
    Member
    Plugin Author

    Posted 1 year ago #

    1.4.5 did not have the custom post logic added, but 1.4.6 will.

  18. publicradio
    Member
    Posted 1 year ago #

    Thanks. I should have downloaded the fork. Instead I just copy/pasted what I thought was all the modified code. When I d/led the fork it worked fine.

  19. Wayne Allen
    Member
    Plugin Author

    Posted 1 year ago #

    1.4.10 will have a couple of fixes for custom post types.

  20. f4iedrich
    Member
    Posted 1 year ago #

    @Wayne. Thanks for the recent updates. I'm trying to understand how to make use of the recent custom post type feature you added..

    Using custom post types, I would like to post in a category named "Lost and Found" with tag_id=1618 and post_type=dailyposts_type for example.

    What's the correct subject line syntax to post some text into this category?

    Many Thanks.
    Bernhard

  21. Raam Dev
    Member
    Posted 1 year ago #

    @f4iedrich: If you look at Dashboard -> Settings -> Postie -> Help, you'll see usage instructions that describe how to do what you're asking.

    So you'd probably want something like this:

    Subject Line:
    dailyposts_type // [Lost and Found] : My Post Title

    Body of Message:

    tags: mytag
    
    This is my example post. The rest of the post content goes here.

    Where 'mytag' is the actual name of tag_id 1618. Again, please read over Dashboard -> Settings -> Postie -> Help for complete details about how to configure Custom Post Types, Categories, and Tags.

  22. f4iedrich
    Member
    Posted 1 year ago #

    Thanks for your reply and detailed example Raam Dev. I'll give it a spin. I appreciate you helping out here!
    B

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags