Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#28253 closed defect (bug) (worksforme)

Cannot delete published post

Reported by: parthiban-sagittarius's profile Parthiban Sagittarius Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9.1
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Hi, I cannot delete the post publish when I programmably insert post into WordPress. Using this part of code:

$post_id = wp_insert_post(
    array(
        'comment_status' => 'closed',
        'ping_status'    => 'closed',	
        'post_status'    => 'publish',
        'post_type'      => 'post',
        'post_title'     => $posttitle,
        'post_content'   => $postcontent,
    )
);  

when there is no value assign to $posttitle and $postcontent, WordPress still create a post without any title and content which I can't delete at all.

Change History (2)

#1 @jigneshkaila
12 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

Hi @Parthiban Sagittarius, thanks for the first bug report!

I have check with your code like below:

array(

        'comment_status' => 'closed',
        'ping_status' => 'closed',
        'post_status' => 'publish',
        'post_type' => 'post',
        'post_title' => $posttitle,
        'post_content' => $postcontent,
        )

    );

it not create any post with empty post_title and post_content.

Note: Please make sure $postcontent variable may overight with other variable.

I have try with below example:

$post_id = wp_insert_post(
    array(
        'comment_status' => 'closed',
        'ping_status' => 'closed',
        'post_status' => 'publish',
        'post_type' => 'post',
        'post_title' => $posttitle,
        'post_content' => 'This is my post.',
        )
    );

it's create post with "(no title)" I mean empty title.

after creation we also delete from admin panel. it's working fine for me.

Please confirm if $postcontent variable should not be overight, let me know for the same.

#2 @SergeyBiryukov
11 years ago

  • Description modified (diff)
  • Milestone Awaiting Review deleted

when there is no value assign to $posttitle and $postcontent, WordPress still create a post without any title and content which I can't delete at all.

Could not reproduce on a clean install. Trying to create an empty post with wp_insert_post() results in an error: "Content, title, and excerpt are empty".

Note: See TracTickets for help on using tickets.