Here is a simple solution..
-
Create a page that you want to use as your redirect handler and get the ID of that page.
-
This goes into your theme’s
functions.php
or any of your plugin file.function wpse405640_redirect() { if ( is_page(123) ) { //Assuming your page id is 123 $redirect = isset($_GET['url']) && !empty($_GET['url']) ? $_GET['url'] : home_url("https://wordpress.stackexchange.com/"); wp_redirect( $redirect ); exit; } } add_action('template_redirect', 'wpse405640_redirect');
The URL structure should be https://myownsite.com/redirect/?url=https://recipes.com/applepie
.
Related Posts:
- Function to return true if current page has child pages
- How do I change/modify the_post_thumbnail(); html output?
- Allow only 1 taxonomy per custom post type [duplicate]
- How to call a PHP function from Javascript in WordPress
- is there a simple way to list every templates / php files used to generate a specific page?
- Check if Favicon is set in Customizer
- Correct way to make static pages editable in wordpress
- How to allow PHP In WordPress text widget
- Update some database fields when post is saved
- If in parent category
- Help with a custom page template – listing contents of childpages?
- WordPress php error after editing file with FileZilla
- Class ‘WP_Widget’ not found
- Second Navigation inside header
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- Listing and displaying WooCommerce Shipping Zones in the frontend? [closed]
- How to insert a local image with custom size
- How can the plugin directory path be returned into ?
- how to trace notice warning on core function is_page() & is_singular in class-wp-query.php
- If meta_value = ‘yes’, then add class?
- WordPress loop causing timeout errors (maximum execution time of 30 seconds exceeded)
- Get the last month with posts using a recursive function…
- A function that returns true when the Author is a certain role is_author(admin)?
- Add a class to the anchor tag on HTML5 gallery
- get_term_link() returns incorrect url
- Conditional Header in wordpress
- How to get all shipping rates and costs without session in woocommerce?
- Display a specific category of products in shop page and disable code for specific actions
- Cannot access wp-admin (wordpress dashboard)
- Trying to build simple deposit code that hooks into woocommerce
- custom rewrite rule help! Custom rewrite rules not applying to custom post type
- Can’t upload image using media_sideload_image
- Saving and Restoring a Canvas on A Individual User Basis
- Get children post mime type using parent post_ID wp_post
- Add class to group inner container
- Databases – Submitting data from inputs to database [closed]
- Is it better to store images and other files in the root directory or the theme directory
- Use .php file as page instead of wordpress page & template file?
- PHP include is only working in certain places in my custom WP theme
- How to get post permalink url without a href
- Find hours between post_date and post_date_gmt
- Resize image to specific dimension (X to Y ratio)
- How to keep track of when a vote is cast?
- Convert the_permalink() function output into string
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Redirection after submitting duplicate comment
- Fatal error: Uncaught Error: Call to undefined function get_header() [closed]
- get_current_site() is undefined
- blank white page when post/update/change option etc
- Incrementing PHP variable onclick to display posts by month
- WordPress PHP syntax doesn’t seem to be working correctly
- Use variable in SQL statement
- How to edit wordpress pages through cpanel? [closed]
- Is it possible to restrict files from your wordpress uploads (not logged-in users or guest)?
- Adding attribute to the post.php form tag in wp-admin
- limit number of post for achive page
- writing an unique php function to be used on my website
- Using Custom Value Options in PHP
- How to get movies by date
- Get options from database using php class
- Problem in replacing the_content with the_excerpt()
- Is there way to toggle the publish date display?
- Need to add a post’s featured image to a section on the frontpage
- How to implement __() function in my theme’s php file?
- remove values within an array user meta
- In PHP how do I make my navigation bar show certain links to admins only?
- Get current user id in function php
- Proper way to remove html code on child theme
- How to pass parameters in wordpress shortcode?
- how to get data from two different table from wordpress database
- Display a custom name when the user has no name settle in his account
- Why can’t I connect to the wordpress install page with Nginx?
- Discount in the specific product title using keyword ( Woocoommerce )
- Can’t make lazy load for my site, help!
- WordPress generates weird permalinks
- WordPress search query, how to modify the sql
- Make a full-width wordpress page
- Modify post image in full size
- Javascript / PHP – closing the loop
- How to link all featured images to custom url in single.php for only non-logged-in users?
- Update an additional user meta field with a string
- number of posts with “Load More”
- Call custom JS function from PHP
- Putting hyperlinked and non-hyperlinked text in one line, centered, on .php [closed]
- Need Quick Help With Product Category Page
- how to remove replicating a tag inside loop?
- My query keeps looping infinitely ! how to stop it?
- blank page when trying to change upload directory
- Why isn’t my link attribute getting my css?
- Retrieve first image url from custom post with pagination
- How to set up and use a custom upload directory for post type ‘product’
- WooCommerce Orders pagination
- Import and use a variable in additional settings of Contact Form 7 [closed]
- How to remove the intro animation which appears during the load up of some WordPress themes? [closed]
- How to send push notification in android using php? [closed]
- use wpdb object on other file
- Field validation strlen works in php7.4 fails 8.1 [closed]
- How do I get a function to work in single.php
- wp_register_script – illegal string offset
- Warning: Undefined property: wpdb::$question_overview in C:\Wamp.NET\sites\proxyvragenmodule\wordpress\wp-includes\class-wpdb.php