问题
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;
}
In the PHP-enabled text widget, I have <?php the_qrcode(the_permalink()); ?>
On the main page, $permalink
is echoed as http://eternityofgamers.com/archives/74http://eternityofgamers.com/forums
instead of http://eternityofgamers.com/archives/74
.
回答1:
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()); ?>
来源:https://stackoverflow.com/questions/11515478/wordpress-widget-issues