I want to be able to search posts by id only in a specific page then automatically redirect users to the searched post. I've found Search Using Post ID answer, which still works. I've also found How to redirect search result page to post which completes my function requirement.
What I want is to combine both and make this whole functionality unique to page id 4629 and not throughout the site's search. Is this possible? How do I achieve that?
Here's what I tried to make this unique to the page so far:
I've added is_page(4629)
after is_search()
in the first snippet but when tested returns no search results. I've also tried wrapping both snippets with if(is_page(4629))
around them, then around each of them but that didn't get any search results too.
Thanks
if(is_page(4629))
but it didn't work. I've also tried adding&& is_page(4629)
after theis_search()
. Nothing worked for me.