Created a text box via metaboxes
I deduce - it also sculpts the address of the current page to the link
Example: on the page http://site.ru/test/ field vk.com/id1/ is added
I put the link and display

$textInput1 = get_post_meta($post->ID, 'mytextinput11', true); <a class="testimonials-link" target="_blank" href="<?php echo $textInput1; ?>" rel = "nofollow"><?php echo $textInput1; ?></a> 

instead of a link like href = "vk.com/id1/" it turns out href = "http://site.ru/test/vk.com/id1/"
How to remove it?

WordPress Version 4.7.4
Theme twentyseventeen standard

    1 answer 1

    It does not WordPress, but html itself, because the link vk.com/id1/ looks like a relative .

    It is necessary either to indicate the full address in the input field, including http:// or https:// , or add a code to php that will check the data from the field and add the missing beginning to it. For example :

     function addhttp($url) { if (!preg_match("~^(?:f|ht)tps?://~i", $url)) { $url = "http://" . $url; } return $url; } 
    • Thank! The truth is that shoals have come out of another place after adding the function, but this is fixable)) - Igor Fostyak
    • one
      By the way, run the esc_url data from the field. This function, among other things, corrects some typos. And what shoals appeared? - Gleb Kemarsky
    • Yes, I hung up on the metaboxing function so that you can only write "id2332" or "usernick" and it itself would add the address vk.com . himself added a job))) - Igor Fostyak