0

I develops elementor widget.my a href code doesnt work like i want.the plugin works like that: admin set a url as text in elementor widget tab.and the text display as link for all equipment div:

 <div class="col-xs-12"> <div class="bag"> <?php $settings = $this->get_settings_for_display(); $html = wp_oembed_get($settings['url']); echo '<a href="'; echo $settings['url']; echo '">'; ?> <div class="dot dot1"> Ekipman </div> </a> 

you can look at the working link:

http://www.migrate2.deniz-tasarim.site/homepage/

bottom of the link page there are box.you should click a box.then click right picture which is equipment (dot1) div.

when you click the equipment div, it opens:

http://www.migrate2.deniz-tasarim.site/homepage/sgdghd.com

however i want only sgdghd.com

3
  • And what does that $settings[‘url’] contain? Commented Feb 11, 2020 at 19:21
  • 1
    It sounds like you have only entered "sgdghd.com" as the URL, and that's not a valid link. Try entering "sgdghd.com" and see if that works without prepending. Commented Feb 11, 2020 at 20:31
  • Smoke detector doesn't like this post Commented Feb 12, 2020 at 0:08

1 Answer 1

0

sgdghd.com is not a complete URL on its own, and if used in a link like <a href="sgdghd.com">, it will be treated as a relative URL. To properly link to a different domain, you need to include http:// or https://.

To ensure that a value for href is a valid URL, you should use esc_url() when outputting it. That way if a user enters an incomplete URL in the settings, it will still be output correctly:

echo '<a href="'; echo esc_url( $settings['url'] ); echo '">'; 
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.