You could use the template_redirect
hook.
https://developer.wordpress.org/reference/hooks/template_redirect/
add_action('template_redirect', 'wpse410342_template_redirect');
function wpse410342_template_redirect() {
if( !is_search() || is_admin() )
return;
global $wp_query;
if( '123456' === $wp_query->get('s') )
wp_redirect( get_permalink( get_page_by_title('Page Name') ) );
}
Using the page slug instead of name.
wp_redirect( get_permalink( get_page_by_path('page-name') ) );
Related Posts:
- How to hook up search results page to a back-end page?
- Add a searchbox to the body of a page
- How to create custom search page
- How to disable page delete
- get_pages() not ordering as it should
- Editing the Number at the end of Page URLs / Editing Page Slugs
- Search through custom post type and custom fields takes 5 minutes
- Pagination Help on Crazy Custom Authors Page
- Create subpage /user/ or /my-profile/ like /author/ with additional query like /user/user123
- Customise search form in the Widget
- Hide page title in WordPress 3.0
- Comment filtering (search)
- Selecting An image from the Media LIbrary on the frontend
- Combine multiple words in custom meta search query
- Custom protected password page with ACF
- Page load requires a trailing “/” [closed]
- Custom search page and search by title, content and tag
- Virtual Pages plugins
- What is the most idiomatic way to let clients edit phrases in HTML?
- How to merge all my pages into one, while keeping a menu bar?
- How to change URL Custom Page?
- redirect product-category to a custom page
- custom headers for static home page and posts page
- Search a post using the date it was posted
- Show posts on a page based on a category and tag(s)
- Setting custom search engine indexing for a “dynamic WordPress page” with htaccess
- Split Conference WordPress Page in different years
- Custom URL going to 404
- Search result page redirect ex.com/?s=searchterms to ex.com/searchterms
- Add google org chart to wordpress page
- Hi, I wanted to make custom search with multiple fields
- How to get custom page template being edited in gutenberg editor
- Steps for custom data retrieval
- custom meta box for page default template
- Custom search to display results within same page
- Search widget will search everything in the site, how to limit to only search gallery name
- Best practice – pages – ACF or inline coding
- How to structure model showcase
- Admin search post meta
- How to customize
- Custom Search on Custom Page while preserving the main search function
- Custom Loop Query For Search Page
- Create page as a file in my theme?
- Featured Image If Else Condition
- Search URL parameters query [duplicate]
- Applying WP-cli Search & Replace to Static SQL Dump File
- Insert menu with a custom walker into page / post body using shortcode?
- How to create “custom page types” with different custom fields in them?
- Creating php pages in wordpress and assigning them to wordpress pages
- How to display page ids as page slug names?
- How to create custom layouts and static pages in themes for clients
- How to make the Pages in WordPress Customized?
- Custom Same Page Search
- change top banner content on specific page
- How to add page content into another page
- How to Add Additional Search Button?
- How to Clear Empty Search values?
- What would causes search to return incorrect results?
- Display a specified content on a Page and all its child pages
- WordPress search on a custom table
- Adding overlay search to wordpress using add action/filter
- Use a custom page with dynamic content as a user profile page
- I want to embed mystream video in my wordpress site
- Swap home page based on user role, Elementor layout breaking
- Taxonomy template is not reading
- Static Page, need Last and Next links at the bottom
- How can I create a Custom Page? (not a page template!!)
- Allow WP users to sort search result on a videos site
- WP_User_Query Search Multiple Keywords from a Multi-Select Field?
- wordpress custom posts page not showing
- How to serve an already coded html page in a WP page, to assign a simpler url
- Custom dropdown search form that allows users to select option B based from Option 1
- Admin menu disable new/delete page
- Show different pages on site depending on user choice
- Custom search results
- WordPress post submit page
- Redirect Every Instance of The Author Template Pages to Custom Author Pages
- Allow arbitrary text after page URL
- WordPress custom search – pagination
- Creating a search with tag variable also added for more detailed results
- Best way to create a page outside of the pages list
- What shortcode should I use for
- Two searchforms with different categories/posts per page
- Search a meta field for a value in all posts
- Want home page to click through to two different page types
- Custom single page based on which custom page template is selected
- Custom search by several options send on form not works
- Page template with custom html fields inside a content
- Pass query param to custom page
- Custom Search Results Page
- WordPress Search on Multiple wp sites
- Create a custom search for Estate Agency WordPress site
- Is there a way to have information on one page automatically feed into another? [closed]
- how to add a page
- How to apply styles to the custom page template
- Sort Search Results in Order of/by Character @ count (9) of post(s) title. (Ocean-WP theme)
- Custom CSS working on home page but not on NEW created PAGE
- Show total sales for each products on search results page Woocommerce
- Custom Search on media files PDF images pages posts
- Create a page for each database table entries