Index: src/wp-includes/post.php
===================================================================
--- src/wp-includes/post.php	(revision 48404)
+++ src/wp-includes/post.php	(working copy)
@@ -6597,8 +6597,9 @@
 	 * @param string|false $date     Date the last post was published. False on failure.
 	 * @param string       $timezone Location to use for getting the post published date.
 	 *                               See get_lastpostdate() for accepted `$timezone` values.
+	 * @param string       $post_type        The post type to check.
 	 */
-	return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date', $post_type ), $timezone );
+	return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date', $post_type ), $timezone, $post_type );
 }
 
 /**
@@ -6636,7 +6637,7 @@
 
 	$lastpostmodified = _get_last_post_time( $timezone, 'modified', $post_type );
 
-	$lastpostdate = get_lastpostdate( $timezone );
+	$lastpostdate = get_lastpostdate( $timezone, $post_type );
 	if ( $lastpostdate > $lastpostmodified ) {
 		$lastpostmodified = $lastpostdate;
 	}
@@ -6645,13 +6646,15 @@
 	 * Filters the most recent time that a post was modified.
 	 *
 	 * @since 2.3.0
+	 * @since 5.4.0 - Add `$post_type` as the third parameter.
 	 *
 	 * @param string|false $lastpostmodified The most recent time that a post was modified, in 'Y-m-d H:i:s' format.
 	 *                                       False on failure.
 	 * @param string       $timezone         Location to use for getting the post modified date.
 	 *                                       See get_lastpostdate() for accepted `$timezone` values.
+	 * @param string       $post_type        The post type to check.
 	 */
-	return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone );
+	return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone, $post_type );
 }
 
 /**
Index: tests/phpunit/tests/post/getLastPostDate.php
===================================================================
--- tests/phpunit/tests/post/getLastPostDate.php	(nonexistent)
+++ tests/phpunit/tests/post/getLastPostDate.php	(working copy)
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * @group post
+ */
+class Tests_Post_GetLastPostDate extends WP_UnitTestCase {
+	/**
+	 * @ticket 47777
+	 */
+	public function test_get_lastpostdate() {
+		$post_post_date_first   = '2018-01-30 16:09:28';
+		$post_post_date_last    = '2018-01-31 16:09:28';
+		$book_post_date_first   = '2019-02-28 18:11:30';
+		$book_post_date_last    = '2019-02-28 18:11:30';
+
+		// Register book post type.
+		register_post_type( 'book', array( 'has_archive' => true ) );
+
+		// Create a simple post.
+		$simple_post_id_first = self::factory()->post->create(
+			array(
+				'post_title'    => 'Simple Post First',
+				'post_type'     => 'post',
+				'post_date'     => $post_post_date_first,
+			)
+		);
+
+		$simple_post_id_last = self::factory()->post->create(
+			array(
+				'post_title'    => 'Simple Post Last',
+				'post_type'     => 'post',
+				'post_date'     => $post_post_date_last,
+			)
+		);
+
+		// Create custom type post
+		$book_cpt_id_first = self::factory()->post->create(
+			array(
+				'post_title'    => 'Book CPT First',
+				'post_type'     => 'book',
+				'post_date'     => $book_post_date_first
+			)
+		);
+
+		$book_cpt_id_last = self::factory()->post->create(
+			array(
+				'post_title'    => 'Book CPT Last',
+				'post_type'     => 'book',
+				'post_date'     => $book_post_date_last
+			)
+		);
+
+
+		// Delete cache to get the updated modified date.
+		wp_cache_delete( $simple_post_id_first, 'posts' );
+		wp_cache_delete( $simple_post_id_last, 'posts' );
+		wp_cache_delete( $book_cpt_id_first, 'posts' );
+		wp_cache_delete( $book_cpt_id_last, 'posts' );
+
+
+		$post_lastpost_date = get_lastpostdate( 'blog', 'post' );
+		$book_lastpost_date = get_lastpostdate( 'blog', 'book' );
+
+		$this->assertEquals( $post_post_date_last, $post_lastpost_date );
+		$this->assertEquals( $book_post_date_last, $book_lastpost_date );
+	}
+}

Property changes on: tests/phpunit/tests/post/getLastPostDate.php
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: tests/phpunit/tests/post/getLastPostModified.php
===================================================================
--- tests/phpunit/tests/post/getLastPostModified.php	(nonexistent)
+++ tests/phpunit/tests/post/getLastPostModified.php	(working copy)
@@ -0,0 +1,119 @@
+<?php
+
+/**
+ * @group post
+ */
+class Tests_Post_GetLastPostModified extends WP_UnitTestCase {
+	/**
+	 * @ticket 47777
+	 */
+	public function test_get_lastpostmodified() {
+		$post_post_date_first          = '2016-01-30 16:09:28';
+		$post_post_modified_date_first = '2016-02-28 17:10:29';
+
+		$post_post_date_last           = '2017-03-30 18:11:30';
+		$post_post_modified_date_last  = '2017-04-30 19:12:31';
+
+		$book_post_date_first          = '2018-05-30 20:09:28';
+		$book_post_modified_date_first = '2018-06-30 21:10:29';
+
+		$book_post_date_last           = '2019-07-30 22:11:30';
+		$book_post_modified_date_last  = '2019-08-30 23:12:31';
+
+		// Register book post type.
+		register_post_type( 'book', array( 'has_archive' => true ) );
+
+		// Create a simple post.
+		$simple_post_id_first = self::factory()->post->create(
+			array(
+				'post_title'    => 'Simple Post First',
+				'post_type'     => 'post',
+				'post_date'     => $post_post_date_first,
+			)
+		);
+
+		$simple_post_id_last = self::factory()->post->create(
+			array(
+				'post_title'    => 'Simple Post Last',
+				'post_type'     => 'post',
+				'post_date'     => $post_post_date_last,
+			)
+		);
+
+		// Create custom type post
+		$book_cpt_id_first = self::factory()->post->create(
+			array(
+				'post_title'    => 'Book CPT First',
+				'post_type'     => 'book',
+				'post_date'     => $book_post_date_first
+			)
+		);
+
+		$book_cpt_id_last = self::factory()->post->create(
+			array(
+				'post_title'    => 'Book CPT Last',
+				'post_type'     => 'book',
+				'post_date'     => $book_post_date_last
+			)
+		);
+
+		// Update `post_modified` and `post_modified_gmt`.
+		global $wpdb;
+
+		$wpdb->update(
+			$wpdb->posts,
+			array(
+				'post_modified'     => $post_post_modified_date_first,
+				'post_modified_gmt' => $post_post_modified_date_first,
+			),
+			array(
+				'ID' => $simple_post_id_first,
+			)
+		);
+
+		$wpdb->update(
+			$wpdb->posts,
+			array(
+				'post_modified'     => $post_post_modified_date_last,
+				'post_modified_gmt' => $post_post_modified_date_last,
+			),
+			array(
+				'ID' => $simple_post_id_last,
+			)
+		);
+
+		$wpdb->update(
+			$wpdb->posts,
+			array(
+				'post_modified'     => $book_post_modified_date_first,
+				'post_modified_gmt' => $book_post_modified_date_first,
+			),
+			array(
+				'ID' => $book_cpt_id_first,
+			)
+		);
+
+		$wpdb->update(
+			$wpdb->posts,
+			array(
+				'post_modified'     => $book_post_modified_date_last,
+				'post_modified_gmt' => $book_post_modified_date_last,
+			),
+			array(
+				'ID' => $book_cpt_id_last,
+			)
+		);
+
+		// Delete cache to get the updated modified date.
+		wp_cache_delete( $simple_post_id_first, 'posts' );
+		wp_cache_delete( $simple_post_id_last, 'posts' );
+		wp_cache_delete( $book_cpt_id_first, 'posts' );
+		wp_cache_delete( $book_cpt_id_last, 'posts' );
+
+		$post_lastpost_modified = get_lastpostmodified( 'blog', 'post' );
+		$book_lastpost_modified = get_lastpostmodified( 'blog', 'book' );
+
+		$this->assertEquals( $post_post_modified_date_last, $post_lastpost_modified );
+		$this->assertEquals( $book_post_modified_date_last, $book_lastpost_modified );
+	}
+}

Property changes on: tests/phpunit/tests/post/getLastPostModified.php
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
