WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how to update or create custom post-types (5 posts)

  1. vincej
    Member
    Posted 3 years ago #

    Hi,
    want to start using custom post types.
    Using an importer now to create new posts with pre-populated info as $mypost
    How is the following done with the custom post-types?
    To be clear: importing this programatically via php script for 100's of posts at a time. ;
    ($mypost is pre-populated array with appropriate values as field info)

    wp_insert_post( $my_post ); ??

    I understand that I could probably skip the post_meta portions as the custom post would have those built in... but I cannot undersand how to do an
    wp_update_custom_post type... I find no reference to this function in the wordpress site.

  2. vtxyzzy
    Member
    Posted 3 years ago #

    If I understand your question, and the Codex article http://codex.wordpress.org/Function_Reference/wp_insert_post, I think you only need to set $my_post['post_type'] to your custom type before calling wp_insert_post.

  3. vincej
    Member
    Posted 3 years ago #

    so in my array I would include
    $my_post['post_type'] = 'product' ;

    and I'm done. just hit wp_insert_post( $my_post ); and I get a product post?

    very cool.
    thanks. vtxyzzy

  4. vtxyzzy
    Member
    Posted 3 years ago #

    You are welcome. If that worked, please use the dropdown at top right to mark this topic 'Resolved' so that others with a similar question can see that there is a solution.

  5. vincej
    Member
    Posted 3 years ago #

    cool,
    done and done, resolved.
    (i'm learning..)

Topic Closed

This topic has been closed to new replies.

About this Topic