• I created a custom post type, and I’m trying to insert post but it is not adding the post_name. Everything else is working fine. I’ve tried manually putting a string within my data array, still no luck. Any suggestions?

    $lottery_tix = array(
    		'post_author' => $user_info->ID,
    		'post_content' => addslashes_gpc($_REQUEST['description']),
    		'post_title' => $post_title,
    		'post_status' => 'pending',
    		'comment_status' => 'open',
    		'ping_status' => 'open',
    		'post_name' => '123',
    		'post_parent' => '0',
    		'guid' => $post_filename,
    		'menu_order' => '0',
    		'post_type' => 'my_stuff',
    		'post_mime_type' => $_FILES['image_filename']['type']
    		);

Viewing 2 replies - 1 through 2 (of 2 total)
  • Is the post_name you’re trying to insert really a numeric value? If so, I’m not 100% sure WordPress allows that. Can you try inserting a post with an alphanumeric post_name instead?

    If I am correct the post_name (slug) is not generated until the post is published, create a test post in the admin area title and content.

    Do not publish it, save as draft and then quick edit and set it to pending and view ‘Screen Options’ and slug to see if it has a value.

    I know that a draft post does not have the post_name which is the post slug

    EDIT
    Just tested ‘Pending Review’, no slug until the post is published!

    HTH

    David

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_insert_post not inserting post_name’ is closed to new replies.