“Where” somewhat depends on the theme you’re using. Here’s couple examples,
-
If you have a custom made theme, then you can put the code in any appropriate place. For example
header.php
(after<head>
) orfooter.php
. -
If you have child theme, then you can copy a suitable
template_part
file from the parent theme to the child dir and add the code to that file. -
Add the code with a action/filter hook. For example
wp_footer
(although the button might look a bit silly with this one) or append it tothe_content
. -
If you don’t need to show the redirected domains content, you could create custom page template and page to which you first redirect all users with
template_redirect
(ortemplate_include
) to serve as a landing page. Then include your custom redirect modal on that page.
Related Posts:
- How to add array [closed]
- Making an under maintenance page (without using plugins)
- How to load scripts/styles specific for a page
- Child theme – Overriding ‘require_once’ in functions.php
- Display random categories on the front page (Finding and Editing Theme Functions)
- Issue with get_theme_mod returning a blank value instead of the saved value
- PHP – redirect https to http and www to non-www
- Masking logout URL
- Logout/login redirect CSS issue
- Hourly Routine Not Firing ( wp_schedule_event() )
- Paged Single Post doesn’t redirect to the main url after Removing Pagination
- which is the function that removes accented vowels?
- redirect wp-login.php to another page
- Theme Demo in live Site
- Customising widget titles/headings in WP 5.8
- How do I redirect upon login a specific user based on role?
- Child Theme Not Overriding Parent Theme
- Redirect if not logged in?
- Where does function_exists() look to decide whether a function exists? [closed]
- Theme-Config tab in admin Pannel?
- Redirect a list of URLs to another URL, using functions.php
- is_user_logged_in not working to redirect only logged out users
- PHP files included in functions.php don’t seem to work
- How to remove howdy dropdown menu content
- Ninja form Redirect depending on text field content [closed]
- Redirect specific page in WordPress for first time visit
- How do I redirect all 404 error url to Subcategory url
- Php function 301 redirect
- How can I change the do_action function in footer (copyright area)
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- changing behaviour of get_search_form
- How to load jQuery in the footer – nothing works for me
- Problem only while using require_once() within functions.php
- Translation of theme using child theme
- Theme functions.php file auto delete everyday [closed]
- Redirect 404 page with ID in slug to associated page with same ID in slug
- WordPress website Rs changed to currency symbol
- 404 redirect to previous category
- Login Redirect if Logged in from Specific Page
- Is there an alternative to get_template_directory_uri()?
- create filter in functions.php
- Add Custom Background Properties to Customizer
- Functions in custom theme
- Parse error after modifying the template menu [closed]
- Redirect to another page if the user is logged in when pressing again the login button on menu bar
- WordPress PHP Conflicting User Sessions
- Using wp_redirect and .htaccess to re-route searches (and pass along the remaining GET vars)
- Incorrect redirect after commenting
- Function that outputs second theme url
- Cannot modify header information – headers already sent (wp_redirect in functions.php)
- Not all CSS elements transferring via parent to child?
- unnecessary request call for js and css after calling wp_dequeue_script
- Turn get_posts as string into an array for use in theme admin options
- Filter nav menu items HTML tags and wrap inner text with span
- Page get parameter doesn’t work with is_single() function
- Can’t switch to a child theme using filters template, option_template and option_stylesheet
- Contact Form 7 If Condition
- Solved: redirect to another page using functions.php
- Redirect to other page if login
- Logout Redirect and also WP-login.php Redirect
- Getting the teaser text without overriding global variables
- WordPress website keeps loading the maintenance page
- Redirects based on a JSON file
- How to override this theme function in child theme
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- How do I preserve changes to a theme’s functions.php across updates?
- template_redirect action only firing if logged in
- What function actually renders the wp_admin_bar ? How can I call it?
- Astra theme – cannot set short product description under the product title (product name)
- How to redirect Subscribers on login to specific page, when logging in from a Page
- Redirect to one of two pages after data submitted, depending on the current url
- Class parameter in get_avatar args doesn’t get added to output
- CSS style and app.js not loading
- Wildcard 301 Redirect Using Theme Function
- Competing Login Redirects – Need to be Combined?
- Postback redirect through add_action is not triggered
- Restrict access if logged out except for homepage
- Redirect specific author posts to another url
- Shortcode Initialization in a Custom Theme
- Custom download page
- Getting back a blank WordPress site following functions code edit
- How to create a function to redirect a specified page to another page
- us states dropdown function and echo in theme template files
- How to pass a variable from a template page to the child theme functions.php
- Language switcher for subdomains
- Random text changing to weird icons in both admin & front end
- Register a widget area when a theme option has been saved?
- Allow the access over wp-login.php
- A blank page is shown after I add a Function
- How does child theme functions.php work with parent theme functions.php? Is it like CSS? [duplicate]
- How to request login for user but not for bots
- Additional Sidebar
- Add custom css to theme
- Which template file to edit to edit homepage in Mystile [closed]
- Adding function to function.php error 505 [closed]
- How to get postId from the argument $block when register_block_type()?
- My website is generating weired url parameters of paginated pages
- Template Redirect Function Only Working When Logged In
- How to automatically load Google Fonts on pages only as they’re used?
- Disable Attachment Page Except for Category