Search page sets a global post

I have customized and styled the search results page search.blade.php according to my needs. The page is loaded in the app layout and the main menu is included in the layout.

I implemented the main menu myself and check which menu items are active by comparing the URL get_permalink() of the current page with the given menu item.

Strangely, on the search page, there is always one menu item active and get_the_ID(); returns an arbitrary page ID. Why is that? Shouldn’t the ID be false or that of the homepage?

I think this is more a general Wordpress question, rather than something roots/sage related. That said, I think using get_the_id() on a pseudo page (like the search page) will return the ID of the first search result – rather than returning false. Hope that’s helpful!

1 Like

Thanks for the quick response. You’re probably right, this is more of a WordPress-specific issue. At first, I thought Sage might still be involved, but it seems to be a standard behavior of WordPress.

1 Like