Make WordPress Core

Opened 5 years ago

Closed 9 months ago

#52742 closed defect (bug) (worksforme)

Searching injects a page ID into the loop if search term matches a page slug

Reported by: marcc1213's profile marcc1213 Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.6.2
Component: General Keywords: close
Focuses: Cc:

Description

Create a page or post with a slug called "test".

Search for "test" using search form. Query string should be ?s=testing

The search page (search.php) will use that page ID in any functions calling "get_the_ID()". Calling get_the_ID() on search.php returns the ID of the page created above.

Change History (2)

#1 @desrosj
3 years ago

  • Keywords close added

Hey @marcc1213,

First, my apologies that this took a such a long time to receive a response.

On to the issue itself. Are you still able to reproduce this? Could you provide some example code? The search page is not an actual page. Instead, it's more like an archive page, or any other psuedo page that lists multiple posts.

It is expected behavior that functions intended for use with a loop to return the corresponding values for the first post in a result set outside of/prior to the loop.

Going to mark this one with a close suggestion since this seems like expected behavior to me. I'll leave it open for a few weeks in case there is more to this report and the more details can be provided.

#2 @karmatosed
9 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

I also agree this feels like regression behaviour and as it has been open for a while without further update I am going to progress through and close. If we get more information to recreate we can reopen. Thank you for the report.

Note: See TracTickets for help on using tickets.