• i want to redirect external link when user search “something” .for example you searched “something”
    you will redirect anothersite.com when you click your ?nstant search result
    how can i make this ?

Viewing 1 replies (of 1 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi Ahmet!

    The only possibility I can think of is to use a custom filter code to change the results URL after the search is done.

    I would do it like this:

    1. Store the external URL in a custom field, for example “asl_custom_url”, like so: https://i.imgur.com/P95uzuR.png

    2. Add this code to the functions.php file in your theme directory:

    
    add_filter( 'asl_results', 'asl_external_url', 1, 1 );
      
    function asl_external_url( $results ) {
      foreach ($results as $k=>$v) {
        $url = get_post_meta($v->id, 'asl_custom_url', true);
        if (!empty($url)) {
          $results[$k]->link = $url;
        }    
      }   
      return $results;
    }

    That should do the trick ??

Viewing 1 replies (of 1 total)
  • The topic ‘How can i do ?’ is closed to new replies.