Php WordPress快捷码功能提供白色页面
我正在为我自己的WordPress主题创建一个短代码。我创造了这个:Php WordPress快捷码功能提供白色页面,php,wordpress,Php,Wordpress,我正在为我自己的WordPress主题创建一个短代码。我创造了这个: function link($atts, $content = null) { extract(shortcode_atts(array( "to" => 'http://net.tutsplus.com' ), $atts)); return '<a href="'.$to.'">'.$content.'</a>'; } add_shortcode("l
function link($atts, $content = null) {
extract(shortcode_atts(array(
"to" => 'http://net.tutsplus.com'
), $atts));
return '<a href="'.$to.'">'.$content.'</a>';
}
add_shortcode("link", "link");
但是,当我在打开和关闭php标记之间将其添加到functions.php时,当我进入任何WordPress页面时,它都会给我一个白色页面。所以wp管理员和普通页面都是白色的
我在functions.php顶部和底部添加了它。两者都不起作用。有人能解释一下我为什么会得到这个吗?请使用这个代码
function mylink($atts, $content = null) {
extract(shortcode_atts(array("to" => 'http://net.tutsplus.com' ), $atts));
return '<a href="'.$to.'">'.$content.'</a>';
}
add_shortcode("mylink", "mylink");
链接是默认关键字,所以不能使用链接
我希望您能获得。根据您的代码: 返回值时不需要使用echo,它应该是这样的:
function infobutton($atts, $content = null) {
extract(shortcode_atts(array("tekst" => 'Meer informatie' ), $atts));
return '<div class="container extend"> <h2 class="center">'.$content.' <a href="pakket" class="button-orange-small">'.$tekst.'</a></h2> </div>';
}
add_shortcode("infobutton", "infobutton");
我现在知道了:函数infobutton$atts,$content=null{extractshortcode_attsarraytekst=>'Meer informatie',$atts;return'。echo$content.';}add_shortcodeinfobutton,infobutton;但它仍然给人一种白色的感觉page@Chiel请编辑您的问题并更新您的问题代码。是的@jogesh_pi是正确的。请在返回某些数据时删除echo语句。我的意思是在$content和$tekstMake之前删除echo语句,确保functions.php文件末尾没有多余的空间
function infobutton($atts, $content = null) {
extract(shortcode_atts(array("tekst" => 'Meer informatie' ), $atts));
return '<div class="container extend"> <h2 class="center">'.$content.' <a href="pakket" class="button-orange-small">'.$tekst.'</a></h2> </div>';
}
add_shortcode("infobutton", "infobutton");