admin管理员组

文章数量:1393092

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 '">';

本文标签: phplta hrefURLgt opens like sitenamecomURL