php - <a href=URL> opens like sitename.comURL

I develops elementor widget.my a href code doesnt work like i want.the plugin works like that: admin set a url as text i

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:

/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:

/homepage/sgdghd

however i want only sgdghd

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

however i want only sgdghd

Share Improve this question asked Feb 11, 2020 at 18:50 ahmet kayaahmet kaya 331 silver badge9 bronze badges 3
  • And what does that $settings[‘url’] contain? – Krzysiek Dróżdż Commented Feb 11, 2020 at 19:21
  • 1 It sounds like you have only entered "sgdghd" as the URL, and that's not a valid link. Try entering "sgdghd" and see if that works without prepending. – WebElaine Commented Feb 11, 2020 at 20:31
  • Smoke detector doesn't like this post – user161710 Commented Feb 12, 2020 at 0:08
Add a comment  | 

1 Answer 1

Reset to default 0

sgdghd is not a complete URL on its own, and if used in a link like <a href="sgdghd">, 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 '">';

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744757107a4591948.html

相关推荐

  • php - &lt;a href=URL&gt; opens like sitename.comURL

    I develops elementor widget.my a href code doesnt work like i want.the plugin works like that: admin set a url as text i

    4小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信