[wp-trac] [WordPress Trac] #53443: The value of the `post_count` meta field is wrong because it doesn't get decremented when a post is deleted

WordPress Trac noreply at wordpress.org
Wed Nov 17 10:56:18 UTC 2021


#53443: The value of the `post_count` meta field is wrong because it doesn't get
decremented when a post is deleted
--------------------------------------+------------------------
 Reporter:  henry.wright              |       Owner:  h
     Type:  defect (bug)              |      Status:  assigned
 Priority:  normal                    |   Milestone:  5.9
Component:  Posts, Post Types         |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  multisite
--------------------------------------+------------------------

Comment (by henry.wright):

 In that case the problem could be the array argument passed to the
 {{{create()}}} method.

 {{{
 array(
     'post_type'   => 'post',
     'post_author' => '1',
     'post_date'   => '2012-10-23 19:34:42',
 )
 }}}

 This will likely be creating a post in draft status because the default
 value for {{{post_status}}} is draft.

 We could try explicitly setting the {{{post_status}}} value to publish.
 {{{update_posts_count()}}} gets a count of published posts only to set the
 post count.

 {{{
 array(
     'post_type'   => 'post',
     'post_author' => '1',
     'post_date'   => '2012-10-23 19:34:42',
     'post_status' => 'publish',
 )
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53443#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list