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
- Redirecting after login except for a specific page
- Add custom css to specific user
- How to redirect using a custom wordpress api endpoint after form submission?
- Missing feature image link function
- What’s the difference between home_url() and site_url()
- Remove “Category:”, “Tag:”, “Author:” from the_archive_title
- get_template_directory_uri pointing to parent theme not child theme
- How to customize the_archive_title()?
- remove empty paragraphs from the_content?
- What is the “with_front” rewrite key?
- Why use if function_exists?
- How to override parent functions in child themes?
- wp_enqueue_script was called incorrectly
- Add multiple custom fields to the general settings page
- Ajax call always returns 0
- 400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
- How long does a deprecated function live in core?
- Solution to render Shortcodes in Admin Editor
- How to add a data attribute to a WordPress menu item
- What’s the difference between esc_html, esc_attr, esc_html_e, and so on?
- remove_action on after_setup_theme not working from child theme
- plugins_url vs plugin_dir_url
- Remove type attribute from script and style tags added by WordPress
- How to run a function every 5 minutes?
- Best way of passing PHP variable between partials?
- How to display custom field in woocommerce orders in admin panel?
- Adding fields to the “Add New User” screen in the dashboard
- Issues with title-tag and document_title_parts
- How do I get the current edit page ID in the admin?
- How to check if a user exists by a given id
- Why isn’t is_page working when I put it in the functions.php file?
- Add tags to the section via functions.php
- Add image size if page template
- How to create a custom order status in woocommerce!
- Remove Actions/Filters added via Anonymous Functions
- Adding a second email address to a completed order in WooCommerce [closed]