[wp-trac] [WordPress Trac] #47777: "get_lastpostmodified" does not seem to return the intended value when using custom post types

WordPress Trac noreply at wordpress.org
Fri Jul 26 05:56:17 UTC 2019


#47777: "get_lastpostmodified" does not seem to return the intended value when
using custom post types
--------------------------+-----------------------------
 Reporter:  mikaumoto     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When I use "get_lastpostmodified" for custom post type,the return value
 was different from what I thought.

 ex.post_type wp,tips

 [[Image(https://usort.jp/wp-content/uploads/image1.png)]]

 sql
 SELECT post_modified FROM wp_posts WHERE post_type='%s' and
 post_status='publish' order by post_modified DESC limit 1
 SELECT post_date FROM wp_posts WHERE post_type='%s' and
 post_status='publish' order by post_date DESC limit 1

 wp-includes\post.php

 {{{#!php
 <?php
         $lastpostdate = get_lastpostdate( $timezone );
         if ( $lastpostdate > $lastpostmodified ) {
                 $lastpostmodified = $lastpostdate;
         }
 }}}

 If understand that when "modified" is older "posted" return value is
 "posted".

 But "lastpostdate" seems "any post_types", I think.


 I tried this code.

 {{{#!php
 <?php
         $lastpostdate = get_lastpostdate( $timezone, $post_type );
         if ( $lastpostdate > $lastpostmodified ) {
                 $lastpostmodified = $lastpostdate;
         }
 }}}

 [[Image(https://usort.jp/wp-content/uploads/image2.png)]]


 As above, I think "get_lastpostmodified" will return the intended value.


 I would like you to consider this matter.
 Thank you.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47777>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list