WordPress.org

Ready to get started?Download WordPress

Forums

Database tables - post to category relationships (3 posts)

  1. nicks0r
    Member
    Posted 6 years ago #

    I am planning to manually insert a post outside of the wordpress front end into the 'wp_posts' table

    To have this post match up with a category I only have to make an entry in the 'wp_term_relationships' table (assuming my category already has and 'term_taxonomy_id' established.

    Does this sound accurate or am I missing anything here?

    Thanks

  2. fitztrev
    Member
    Posted 6 years ago #

    The easiest way is to call the wp_insert_post() function.

    Do a 'require' of wp-blog-header.php in your script and you'll be able to call it. You pass wp_insert_post() an array that contains all the post info and the categories/tags and it will take care of the rest.

  3. fitztrev
    Member
    Posted 6 years ago #

    P.S. There are also these 2 functions which may be helpful, although wp_insert_post already incorporates them:

    wp_set_post_categories()
    wp_set_post_tags()

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.