任何人都可以告訴我爲什麼wordpress'頁面模板'中的代碼不會執行嗎?WordPress頁面模板中的PHP代碼不會執行
'回聲'似乎工作,但所有'包括'和'print_r()'和其他功能不。這個確切的代碼工作我的主服務器上而不是在WordPress的託管網站:
<?php
/**
* Template Name: fbshares
*
* A custom page template for displaying all posts.
*
* The "Template Name:" bit above allows this to be selectable
* from a dropdown menu on the edit page screen.
*
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
*/
get_header(); ?>
<div id="container">
<div id="content" role="main" class="fullpagejoel">
<?php
echo "x";
$url = "http://www.google.com";
$social = array(
'twitter' => 'http://cdn.api.twitter.com/1/urls/count.json?url=',
'facebook' => 'https://graph.facebook.com/',
'stumbleupon' => 'http://www.stumbleupon.com/services/1.01/badge.getinfo?url='
);
$json = file_get_contents($social['twitter'].$url, false);
$a = json_decode($json, true);
$r['twitter'] = $a['count'];
print_r($a);
echo count($a).' [OK]';
?>
你怎麼能說它不起作用?你有錯誤嗎? 'include'在哪裏? – hakre
我拿走了包括並嘗試調試。我把代碼直接放在頁面中(你在那裏看到的)。沒有任何錯誤。只是一個「退出」。我無法通過設置error_reporting(E_ALL)給出錯誤消息;' – Joel
StackOverflow不是調試服務。我們不會猜測你是否有錯誤或等待你嘗試不同的事情。你可能想嘗試Code Review。 – Kermit