How to add variables to the “redirect to url” or the “show more url”?

This will only work on plugin version 4.9.5 or later!

Both strings are filtered before output, so you can use a custom function to do the job:

What is this, and where do I put this custom code? Change the $values array to add/remove query param=>value pairs.

// Use this to change the "redirect to url" parameter
add_filter( 'asp_redirect_url', 'asp_add_params_to_url', 1, 10 );
// Use this to change the "show more results url" parameter
add_filter( 'asp_show_more_url', 'asp_add_params_to_url', 1, 10 );

function asp_add_params_to_url( $url ) {
  // Array of param names and values
  $values = array(
    "param1" => "value1",
    "param2" => "value2",
    "param3" => "value3"
  );
  // Merge them together
  foreach ( $values as $k => $v )
    $url .= "&".$k."=".$v;
  
  return $url;
}

Last updated