title: Wordpress: add custom params to all URLS
body: <p>I have an addition to url e.g. /products/myproduct/?v=iphone-x/transparent/*/Green</p>
  
  <p>So what I need is for wordpress to add the ?v=iphone-x/transparent/*/Green to all links on the page (only '<code>&lt;a href=""&gt;</code>'s, no '<code>img src=""</code>' or others)</p>
  
  <p>I have managed to do that, but it's a little "dirty". Is there any neat function to  add the parameter to all links?</p>
  
  <p>The code I have is as follows: </p>
  
  <pre><code>function callback($buffer) {
    // modify buffer here, and then return the updated code
    $temp = explode('href="', $buffer);
  
    $buffer = $temp[0];
    array_shift($temp);
  
    foreach($temp as $t){
        $tt = explode('"', $t, 2);
  
        $buffer .= 'href="'.$tt[0].'?v='.$_GET['v'].'"'.$tt[1];
    }
  
    return $buffer;
  }
  
  function buffer_start() { ob_start("callback"); }
  
  function buffer_end() { ob_end_flush(); }
  
  add_action('wp_head', 'buffer_start');
  add_action('wp_footer', 'buffer_end');
  </code></pre>