function custom_function_redirect() {
if ( isset( $_GET[ 'link' ] ) && $_GET[ 'link' ] != '' ) {
wp_redirect( $_GET[ 'link' ], 301 );
}else{
die('test');
}
}
add_action('template_redirect','custom_function_redirect');
Try this it worked for me.
For redirection you should hook the function in template_redirect
Related Posts:
- Upload Multiple Files With media_handle_upload
- What is this code in my theme’s functions.php? if (isset($_REQUEST[‘action’]) && isset($_REQUEST[‘password’])
- Masking logout URL
- Logout/login redirect CSS issue
- Paged Single Post doesn’t redirect to the main url after Removing Pagination
- redirect wp-login.php to another page
- VERY new to coding – keep breaking site trying to add to functions.php
- Problem with tag
- write in functions.php
- How do I redirect upon login a specific user based on role?
- Pinterest Integration Using functions.php
- Date/time limitation of posts where function must be executed
- Completely disable RSS feeds on WP 5.5.2 and show a 404 page instead of die();
- 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
- Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘greenday_head’ not found or invalid function name
- 404 redirect to previous category
- Login Redirect if Logged in from Specific Page
- Redirect to another page if the user is logged in when pressing again the login button on menu bar
- Incorrect redirect after commenting
- How can this crude function be improved?
- How to run a function in every page, every device
- Why does get_template_directory_uri() not include “www”, only for enqueued stylesheets?
- Numbering lines of code with the tag?
- Page get parameter doesn’t work with is_single() function
- Redirect website domain (including all pages) to external URL after Popup message (few seconds)
- 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
- How to add array [closed]
- WordPress website keeps loading the maintenance page
- Redirects based on a JSON file
- template_redirect action only firing if logged in
- How to redirect Subscribers on login to specific page, when logging in from a Page
- Save Meta when custom Taxonomy Saves
- remove edit link only for published post and pending post
- Redirect to one of two pages after data submitted, depending on the current url
- Adding a schema code to one specific page using functions.php file
- How set a while with a function
- 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
- Drop down list code for sidebar
- Custom download page
- Some code is added automatically to my site’s header – what is it?
- How to include a hyperlink in the body text of a custom password protected form?
- How to create a function to redirect a specified page to another page
- Language switcher for subdomains
- Allow the access over wp-login.php
- How to get tags and categories?
- How to request login for user but not for bots
- How to add a class name to the ancestor of a post?
- Making an under maintenance page (without using plugins)
- Code in functions.php appearing on front-end and dashboard [closed]
- I want to add the alt attribute to all the photos!
- Bad value crossorigin for attribute crossorigin on element link
- Text before price on WooCom
- Template Redirect Function Only Working When Logged In
- Convert Image to Webp on upload without plugin
- Disable Attachment Page Except for Category
- Ajax call always returns 0
- Where and how to put inline js in pages
- PHP – redirect https to http and www to non-www
- Overriding methods in a child theme
- WP disobeys disabling of the posts revision feature
- Having a Function Inside of the Loop
- Unable to login using username
- How to change the order of Jquery in the footer of my theme?
- media resize/crop possibilities?
- adding custom script to functions file
- add_action template_redirect not working for home page
- Way to store featured image width and height in two separate variables?
- Insert template-part inside the content
- How do I change a parent theme’s function through the child theme?
- Dropline menus — seperators between children only?
- Echoing function into WordPress NextGen gallery
- 404 when enqueue_script using plugin_url
- WP Customizer API loaded into functions.php
- the_widget() inside functions.php
- How Can I add a menu to the theme from withen the function.php file
- How to hide content on mobile in the functions.php file – woocommerce
- Load templates, pass arguments, and render output from functions.php
- WordPress Lite/Light
- Is_Page doesnt detect my page
- Problems adding a new field to product in cart
- Function for Sticky Post on Categories causes issues with 404 behavior
- Get value of pre-populated Gravity forms field as variable in my function
- Create html from function
- wp_list_pages change of children and anchor of parent
- Admin Panel errors because of functions.php
- WordPress not performing direct update
- Using Output from one Function and calling it into another
- How to add a class and title attribute to the link generated by next/previous post
- “Headers already sent” while trying to add a CSS file to my login page?
- Notice: Use of undefined constant REQUEST_URI – assumed ‘REQUEST_URI’ in ….functions.php on line 73
- comment_post function with js not running