Skip to content

Commit

Permalink
fix: the empty object being passed for the wp_query object
Browse files Browse the repository at this point in the history
  • Loading branch information
Juzar10 committed Dec 10, 2024
1 parent a1079b6 commit c6a1534
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/wp-includes/class-wp-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -3662,14 +3662,24 @@ private function set_found_posts( $q, $limits ) {
*
* @since 1.5.0
*
* @return WP_Post Next post.
* @return WP_Post|int Next post.
*/
public function next_post() {

++$this->current_post;

/** @var WP_Post */
$this->post = $this->posts[ $this->current_post ];
if ( $this->posts[ $this->current_post ] instanceof WP_Post ) {
$this->post = $this->posts[ $this->current_post ];
} else {
$current_item = $this->posts[ $this->current_post ];

if ( is_object( $current_item ) && property_exists( $current_item, 'ID' ) ) {
$this->post = $current_item->ID;
} else {
$this->post = $current_item;
}
}

return $this->post;
}

Expand Down

0 comments on commit c6a1534

Please sign in to comment.