1

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

3
  • It's possible. What have you done by far to that effect and what challenge are you facing? Dec 28, 2016 at 15:00
  • I'm new to this so my trials may not be sensible to you. I tried to wrap the whole thing like if(is_page(4629)) but it didn't work. I've also tried adding && is_page(4629) after the is_search(). Nothing worked for me.
    – hjaffer
    Dec 28, 2016 at 15:06
  • 1
    Do update your post with that detail as well as the error(s) you are getting. Please note that this medium is NOT for tutorial but to assist developers and or learners, with conscious effort when facing a challenge in their line of duty. New to coding? Take a step at a time and don't bite more than you can chew; hire a developer as you learn and grow with time. All the same, just demonstrate you are putting in as much effort to achieve; not to be freely fed, and the community will gladly assist you. Dec 28, 2016 at 15:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.