• Resolved Yoav Rheims

    (@yoav1987)


    For a project, we need to change the default URLs to an external website.

    Is that something possible? We did exactly that for WordPress using some hack in the function.php of the theme.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Yoav Rheims

    (@yoav1987)

    So, I’ve followed this tutorial successfully: https://www.wpbeginner.com/wp-tutorials/how-to-link-to-external-links-from-the-post-title-in-wordpress/ but I’d like to do the same for all results from Ajax Search Lite plugin.

    How can I do that?

    Plugin Author wpdreams

    (@wpdreams)

    Hi!

    I’m assuming, you are using a custom field to store the custom URLs?

    In that case, it is possible to change that after the post-processing, with a custom code (placing it to the functions.php file):

    add_filter( 'asl_pagepost_results', 'asl_change_link_to_meta', 1, 1 );
    function asl_change_link_to_meta( $results ) {
      $custom_field = 'custom_url_field'; // Change this to the custom field name
      // -----------------------------------------------
      foreach ($results as $k=>$v) {
        $meta = get_post_meta($v->id, $custom_field, true);
        if ( !empty($meta) ) {
          $results[$k]->link = $meta;
        }  
      }   
      return $results;
    }

    Just make sure to change the $custom_field variable to the custom field that holds the url.

    Best,
    Ernest Marcinko

    Thread Starter Yoav Rheims

    (@yoav1987)

    Ernest, you’re awesome!

    Plugin Author wpdreams

    (@wpdreams)

    Thanks ??

    Will mark this as resolved for now. Feel free to rate the plug-in if you want to.

    Best regards,
    Ernest

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change URLs to external’ is closed to new replies.