WordPress.org

Ready to get started?Download WordPress

Forums

404 Redirected
Query arg is removed (3 posts)

  1. metaphorcreations
    Member
    Posted 7 months ago #

    I'm trying to add query args to my links, but they keep getting stripped off the url when this plugin is activated. Is there a way around this?

    Thanks!

    http://wordpress.org/plugins/404-redirected/

  2. styledev
    Member
    Posted 3 months ago #

    This is a major bug. It should respect the query_vars filter!

  3. DaanMeijer
    Member
    Posted 1 month ago #

    I've created a workaround class, which can be copied into functions.php:

    class Bypass404Redirect {
    	function __construct(){
    		add_action('template_redirect', array($this, 'strip'), 9);
    		add_action('template_redirect', array($this, 'restore'), 11);
    	}
    	private $uri = '';
    
    	function strip(){
    		$this->uri = $_SERVER['REQUEST_URI'];
    		$_SERVER['REQUEST_URI'] = preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']);
    	}
    
    	function restore(){
    		$_SERVER['REQUEST_URI'] = $this->uri;
    	}
    }
    new Bypass404Redirect();

Reply

You must log in to post.

About this Plugin

About this Topic