Wordpress 小部件问题 [英] Wordpress Widget Issues
问题描述
我正在尝试使用 PHP 显示当前页面的二维码.the_permalink()
在我的论坛上返回空白.
I'm trying to use PHP to display a QR code for the current page. the_permalink()
returns as blank on my Forums.
function the_qrcode( $permalink ) {
if($permalink == '') {
$permalink = 'http://eternityofgamers.com/forums';
}
echo $permalink;
}
在支持 PHP 的文本小部件中,我有 <?php the_qrcode(the_permalink());?>
In the PHP-enabled text widget, I have <?php the_qrcode(the_permalink()); ?>
在主页面上,$permalink
回显为 http://eternityofgamers.com/archives/74http://eternityofgamers.com/forums
而不是 http://eternityofgamers.com/archives/74
.
On the main page, $permalink
is echoed as http://eternityofgamers.com/archives/74http://eternityofgamers.com/forums
instead of http://eternityofgamers.com/archives/74
.
推荐答案
the_permalink() 应该在循环中使用.如果您想获取当前的帖子链接,请使用 get_permalink.
The the_permalink() should be used in a Loop. If you want to get the the current post link, use the get_permalink.
<?php the_qrcode(get_permalink()); ?>
这篇关于Wordpress 小部件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!