Forums

wp_insert_post with custom columns? (5 posts)

  1. tehjrow
    Member
    Posted 1 year ago #

    I understand that wp_insert_post inserts things into the wp_posts table.

    If i make a custom column in that database and put it in the wp_insert_post array, will it be inserted?

  2. tehjrow
    Member
    Posted 1 year ago #

    Never mind, found this.

    The user can provide more elements than are listed here by simply defining new keys in the database. The keys should match the names of the columns in the wp_posts table in the database.

  3. tehjrow
    Member
    Posted 1 year ago #

    Ok it's not working.

    I made a new column in wp_posts called post_location.

    $my_post = array(
           		'post_title' => $_POST['Title'],
           		'post_content' => $_POST['Message'],
    		'post_status' => $my_post_type,
           		'post_author' => $user_id,
           		'post_category' => $category,
           	        'comment_status' => (($enableComments && !$use_anonComment)  ? 'open' : 'closed'),
           		'ping_status' => 'closed',
    		'post_location' => 'isitposting'
           	);

    When i use this array with wp_insert_post it inserts everything in the array except post_location. Why?

  4. tehjrow
    Member
    Posted 1 year ago #

    Ok yeah, i've been messing with it and I can't figure it out. Is there any way I can echo out the SQL that is being ran?

  5. tehjrow
    Member
    Posted 1 year ago #

    So i'm just going to use add_post_meta, it works.

Topic Closed

This topic has been closed to new replies.

About this Topic