admin管理员组文章数量:1323323
I am a little stuck in one situation. I am removing some errors from my site and got one unexpected error here below is my code:-
<?PHP
$release_web_url = get_post_meta( get_the_ID(), '_links', true );
print_r($release_web_url) ; ?>
and the output of this code is:
Array ( [0] => Array ( [name] => Website [url] =>www.google ) )
I only want to echo the array URL value in the anchor HTML tag. So I did this coding below:
foreach($release_web_url as $item): ?>
<a href="<?php echo $item['url']; ?>">Website</a>
<?php endforeach;
now instead of getting anchor link = www.google | I got anchor link = 192.168.1.50/jobifylocal/www.google | that thing doesn't make any sense adding the other URL automatically in-front of the given URL.
I am a little stuck in one situation. I am removing some errors from my site and got one unexpected error here below is my code:-
<?PHP
$release_web_url = get_post_meta( get_the_ID(), '_links', true );
print_r($release_web_url) ; ?>
and the output of this code is:
Array ( [0] => Array ( [name] => Website [url] =>www.google ) )
I only want to echo the array URL value in the anchor HTML tag. So I did this coding below:
foreach($release_web_url as $item): ?>
<a href="<?php echo $item['url']; ?>">Website</a>
<?php endforeach;
now instead of getting anchor link = www.google | I got anchor link = 192.168.1.50/jobifylocal/www.google | that thing doesn't make any sense adding the other URL automatically in-front of the given URL.
Share Improve this question edited Sep 2, 2020 at 11:57 bueltge 17.1k7 gold badges62 silver badges97 bronze badges asked Sep 2, 2020 at 11:40 fyn matt 881fyn matt 881 32 bronze badges 1 |1 Answer
Reset to default 2You’ve forgotten the https://
. This will happen in any HTML where you don’t add the protocol to a URL. Nothing to do with WordPress.
However, you should use esc_url()
when outputting user entered values into a link, to make sure the output is a valid URL, even if the user makes this same mistake:
<a href="<?php echo esc_url( $item['url'] ); ?>">Website</a>
本文标签: pluginsa href adds default URL with the given echo URL
版权声明:本文标题:plugins - a href adds default URL with the given echo URL 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742142474a2422643.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
<a href="www.google">
, the browser is showing you were that leads, it's not a WP bug, see Jacobs answer for why and how to fix it – Tom J Nowell ♦ Commented Sep 2, 2020 at 12:11