我在使用的主题中添加了短代码,但当我尝试在页面中使用它们时,它会给我一个空白页面。我看到了一个解决这个问题的方法remove_filter("the_content", "wpautop");
但我不确定这是否有效。如果会,请让我知道,请让我知道该代码放在哪里。否则,如何解决此问题。如果您需要查看我正在尝试添加哪些短代码,请告诉我,我将随它们一起发布一个文件。提前谢谢。
EDIT 下面是我用来添加短代码的函数:
function facebook($atts) {
extract(shortcode_atts(array(
"source_url" => \'https://www.facebook.com/the569a/\'
), $atts));
$url = "http://api.facebook.com/restserver.php?method=links.getStats&urls=".urlencode($source_url);
$xml = file_get_contents($url);
$xml = simplexml_load_string($xml);
$likes = $xml->link_stat->like_count;
return \'<div class="column"><a href="\' . $source_url . \'"><i class="fa fa-facebook" style="color: white; border: 1px solid white; border-radius: 100%; font-size: 28px; height: 38px; line-height: 40px; margin: 5px; text-align: center; width: 38px;" aria-hidden="true"></i><span style="font-size: 150%;">\' . $likes . \' likes</span></a></div>\';
}
add_shortcode("facebook", "facebook");
function twitter($atts) {
extract(shortcode_atts(array(
"user_id" => \'team569A\',
"link" => \'http://www.twitter.com\'
), $atts));
$xml = new SimpleXMLElement(urlencode(strip_tags(\'https://twitter.com/users/\'.$user_id.\'.xml\')), null, true);
return \'<div class="column"><a href="\' . $link . \'"><i class="fa fa-twitter" style="color: white; border: 1px solid white; border-radius: 100%; font-size: 28px; height: 38px; line-height: 40px; margin: 5px; text-align: center; width: 38px;" aria-hidden="true"></i><span style="font-size: 150%;">\' . $xml->followers_count . \' followers</span></a></div>\';
}
add_shortcode("twitter", "twitter");
function instagram($atts) {
extract(shortcode_atts(array(
"username" => \'569A_\',
"link" => \'http://www.instagram.com\'
), $atts));
$raw = file_get_contents(\'https://www.instagram.com/\'.$username);
preg_match(\'/\\"followed_by\\"\\:\\s?\\{\\"count\\"\\:\\s?([0-9]+)/\',$raw,$m);
return \'<div class="column"><a href="\' . $link . \'"><i class="fa fa-instagram" style="color: white; border: 1px solid white; border-radius: 100%; font-size: 28px; height: 38px; line-height: 40px; margin: 5px; text-align: center; width: 38px;" aria-hidden="true"></i><span style="font-size: 150%;">\' . intval($m[1]) . \' followers</span></a></div>\';
}
add_shortcode("instagram", "instagram");
function discord($atts) {
extract(shortcode_atts(array(
"server_code" => \'365923825860214784\',
"link" => \'https://discordapp.com/invite/FjuqqFc\'
), $atts));
$JsonIn = file_get_contents(\'https://discordapp.com/api/guilds/\'.$server_code.\'/embed.json\');
$JSON = json_decode($jsonIn, true);
$membersCount = count($JSON[\'members\']);
return \'<div class="column"><a href="\'.$link.\'"><i class="fa fa-687474703a2f2f692e696d6775722e636f6d2f65597779386c" style="color: white; border: 1px solid white; border-radius: 100%; font-size: 28px; height: 38px; line-height: 40px; margin: 5px; text-align: center; width: 38px;" aria-hidden="true"></i><span style="font-size: 150%;">\'. $membersCount . \' members</span></a></div>\';
}
add_shortcode("discord", "discord");
我目前无权访问该错误。日志文件 我会注意到,并不是整个页面都是空白的。主题和页面标题仍会显示,但页面内容不会显示。
EDIT 2 我只是去寻找错误。日志文件,但似乎没有。我不知道接下来该怎么办。