Commit 2096a25ea9 for wordpress.org
commit 2096a25ea96e7b041a1bc7055d6ed59cbef3eaf9
Author: lancewillett <lancewillett@git.wordpress.org>
Date: Sat Oct 31 21:09:53 2026 +0000
Posts, Post Types: Allow boundary post lookups outside single posts.
Allow `get_boundary_post()` to return the first or last post on non-singular pages. Retain the missing-post guard when `$in_same_term` needs a current post, and continue rejecting unknown taxonomies.
Add coverage for non-singular lookups and the missing-post case.
Developed in: https://github.com/WordPress/wordpress-develop/pull/9200, https://github.com/WordPress/wordpress-develop/pull/9040
Props pathawks, sirlouen, iamadisingh, mukesh27, devasheeshkaul.
Fixes #22957.
Built from https://develop.svn.wordpress.org/trunk@65151
git-svn-id: http://core.svn.wordpress.org/trunk@64300 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
index f6bd62e0e3..aabf7bc69d 100644
--- a/wp-includes/link-template.php
+++ b/wp-includes/link-template.php
@@ -2209,9 +2209,13 @@ function prev_post_rel_link( $title = '%title', $in_same_term = false, $excluded
* @return array|null Array containing the boundary post object if successful, null otherwise.
*/
function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) {
+ if ( ! taxonomy_exists( $taxonomy ) ) {
+ return null;
+ }
+
$post = get_post();
- if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) ) {
+ if ( $in_same_term && ! $post ) {
return null;
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 9513c95914..6d80dc9232 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta3-65150';
+$wp_version = '7.2-beta3-65151';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.