Make WordPress Core

Opened 14 months ago

Closed 13 months ago

Last modified 4 months ago

#58111 closed defect (bug) (duplicate)

Main loop is not working in some cases with "Post Featured Image" block

Reported by: engahmeds3ed's profile engahmeds3ed Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.2
Component: General Keywords: has-testing-info
Focuses: Cc:


Steps to reproduce:

  1. Create a post that has the block "Post Featured Image"
  2. Use the following snippet
    add_action( 'wp_head', function () {
            if ( ! is_singular() ) {
            $post = get_queried_object();
            apply_filters( 'the_content', $post->post_content );
    } );
  3. Visit the created post page in frontent.
  4. You will find the page content part is empty.

I believe this is because:

We are outside the loop (inside wp_head hook), the function the_post will be called and then $wp_query->current_post will be increased from -1 to be 0 so the next loop (main content loop) will not fire because of that.

Change History (5)

This ticket was mentioned in Slack in #core-test by ironprogrammer. View the logs.

13 months ago

#2 @annashopina
13 months ago

  • Keywords has-testing-info added

#3 @annashopina
13 months ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #58027.

#4 @annashopina
13 months ago

The task was linked with for future investigation. Looks like they are duplicated.

#5 @swissspidy
4 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.