Wordpress Widget Issues

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 19:33:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!