You’re not passing the actual querystring to remove_query_arg()
. After some quick testing, I think your $location
value is probably an empty string, and the location you’re attempting to redirect to is ?isPwa
.
The 2nd parameter to remove_query_arg()
should be the $referer
value.
function addIsPwaQueryArg() {
$referer = wp_get_referer();
if (strpos($referer, 'isPwa') !== false) {
$location = remove_query_arg('isPwa', $referer );
wp_redirect(add_query_arg('isPwa', '', $location));
exit;
}
}
add_action('template_redirect', 'addIsPwaQueryArg');
However: I’m not sure that’s the root cause of your redirect loop. It looks like you’re checking to see if isPwa
is in the querystring, removing it if it is, and then adding it back in (with a blanked value) as you redirect. Is this your intent?
Related Posts:
- wp_redirect on base wp-admin and login
- How to redirect home page to another page after login for all user?
- Redirect returning users to a certain page?
- template_include (overriding default plugin templates via current theme)
- Using a Theme inside a Plugin directory
- Front-End Form Submission in Shortcode
- Cannot modify header information – headers already sent by pluggable.php
- Change template dynamically
- Translation per IP location [closed]
- Force HTTPS 301 redirect with hook
- Redirect in WordPress plugin
- Add code to template dynamically
- send popup after wp_redirect()
- Information and Page from WordPress Plugin
- get_queried_object_id combined with wp_redirect gets wrong id
- redirect_to how to make it simply work with get parameter or similar?
- Multi-part form and wp_redirect()
- Woocommerce Single Product Tabs Got Duplicate
- Replace the WordPress Media Library Uploader
- How to prevent users from deleting their accounts?
- Performing ajax request in wordpress
- How do I get a reference to the HTML memory buffer while the page is being constructed?
- do_action from within a class does not seem to work
- How to create save function for custom Gutenberg style block?
- Warning: Illegal string offset ‘Andorra’ in … on line 106
- Woocommerce product not appearing in category list page when created programatically [closed]
- Inserted data from database does not showing on front-page without referesh page?
- Error when activating a custom plugin on production server
- Remove tag from all posts when publishing new post
- add_meta_box does not display meta box in Admin
- How to call a plugin function from a page
- Allow user to add the php code in wp_mail()
- Custom Plugin activation error in Multisite
- The Events Calendar featured image as body background?
- woocommerce wc_get_product is not fetching all the product of particular category
- Integrating colorpicker into array field
- WordPress plugin how to run function when button is clicked
- wp_ajax function return the html page
- Buddy Press restrict the capability to edit users
- Override WooCommerce files from plugin
- using wordpress acf shortcods in tables goes outside the table
- Add WordPress Meta Box saved form input to WordPress RSS feed [duplicate]
- $_SESSION inside php function executed by AJAX
- Two same AJAX calls – one is working, other doesn’t
- ajax multiple Values
- Internal redirect from page to category
- Change Label of custom post type
- BuddyPress and namespacing
- Hiding class namespace from plugin’s extensions
- OOP development and hooks
- woocommerce add a new bulk action in the bulk actions dropdown in the orders list
- How to trigger WooCommerce user profile edit change?
- Creating a virtual page without exit
- How to include files in the loop via ajax
- Return raw image proxy for wordpress plugin
- Yoast and another plugin
- How to set a public variable in someone else’s plugin class
- Plugin Development – Call to undefined function comment_exists()
- How to handle ajax Request in a complex-structured plugin?
- Replace “content-area” of themes 404 page with plugin?
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- Override theme’s WooCommerce file
- TinyMCE 4.7.11 – Enable hidden WordPress core plugins? (referencing a wp-includes from plugin.php)
- Use admin-post to submit form data to external database
- How to create plugin settings page for each admin user?
- Plugin removes itself if mistake made during edit
- Using meta_key & meta_value in add_rewrite_rule
- Using JavaScript in WordPress page to call for server data using AJAX
- implementing socket.io with wordpress
- Code for cron to delete posts that contain specific expression (e.g. “unable to fetch” every 30 minutes
- wp_editor embed shortcode not working within my plugin
- If user is logged-in display/hide widgets ( siteorigine) [closed]
- Javascript not being loaded only in custom taxonomy template
- User avatar-ACF fields
- wp_ajax add_action fuction won’t fire on custom jQuery action
- How can I specify the plugin language in WordPress?
- WC_Geolocation not found inside plugin
- Set widget icon in Customizer?
- Add new header/footer on landing page with plugin
- bindParam? WordPress 4.9.5 SQL LIKE statement %s and %LIKE%
- tweaking the
- Redirect theme directory to plugin theme directory
- Hiding WordPress REST endpoints from public viewing using Basic Authentication
- Save in my custom admin page and redirect to the saved object
- Plugin setting page – update_option problem
- Plugin with functions inside a class & how to trigger WP CRON
- Pass javascript result to shortcode executer function
- Filterable posts using categories
- How to get values from Tinymce visual editor popup?
- “Headers Already Sent” Nightmare on Plugin
- remove different admin menu for specific users
- add pagination to wp_remote_get
- Where to store Plugin specific information in the database
- One-way DB Migration Workflow
- Adding and handling custom settings tab to fusion element
- set a custom post type to a taxonomy term programmatically in metabox
- WordPress Reset password Strength set to medium
- Ajax Response Error | just getting error as the response
- Custom premium registration form and profile page for a WordPress Web Application
- Add a Script button in W3 Total Cache plugin not working due to conflicting jQuery version