• Lets imagine i have a landing page who gets an affiliate id by parameter, which should be passed to the shop, when the user wants to buy.

    If my wordpress page gets an parameter like this:

    mypage.org/puppy-landingpage/?aff=3

    i want to pass it to my links via the page editor (not template) like this: editor code view:

    <p>click <a href="www.shop.com<strong>?aff=[getparam 'aff']">here</a> to buy</p>

    so a click on the link will lead to

    shop.com/?aff=3

    very simple but i didnt find a plugin or solution.
    thanks for help

    • This topic was modified 2 years, 4 months ago by elvis9999.
Viewing 1 replies (of 1 total)
  • Mario Santos

    (@santosguillamot)

    Hi @elvis9999!

    I found this topic in WordPress StackExchange (with a solution) with a use case really similar to yours if I understood it correctly. I’ve tested it, and it seems to work fine. When I arrive at the homepage with the aff param, it is preserved while navigating. This is the code I added to test it, I guess you’d need to do some modifications like they are suggesting in the answer, because the query is hardcoded here:

    function wprdcv_param_redirect(){
    if( !is_admin() && !isset($_GET['aff']) ){
        $location = "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
        $location .= "?aff=abc";
        wp_redirect( $location );
    }
    }
    
    add_action('template_redirect', 'wprdcv_param_redirect'); 

    You could add that to your functions.php or use a plugin like Code Snippets. I recommend doing it on a staging site before testing in production.

    Let us know if it works!

    • This reply was modified 2 years, 4 months ago by Mario Santos.
    • This reply was modified 2 years, 4 months ago by Mario Santos.
Viewing 1 replies (of 1 total)
  • The topic ‘Forward URL Parameter to Links in Page’ is closed to new replies.