0
使用wordpress作爲我的基礎,我需要輸出所有帖子的帖子元,但只能輸出一定數量的鍵。將鍵和元數據保存到數組中 - Wordpress
我打算做的是保存我所有密鑰的列表,即將用於查詢wordpress的元數據的帖子。
以下是我的代碼。
//HERE YOU CAN SEE THE KEYS IMM USING ATM
$nyckellista[] = array("ebutik_allm_bas_operativsystem" ,"--foretagsform"
,"ebutik_allm_bas_omsättning");
$i = 0;
//Here im trying to query the get_post_meta with my keys and save the result (it's an array aof values that it return)
foreach($nyckellista as $nyckel)
{
$nyckellista[$i] = get_post_meta($post->ID,$nyckel,false);
echo $i . "Nyckel:" . $nyckel[$i];
$i++;
}
//HERE ME TRYING TO PRINT THE ARRAY CONTENTS
$count = count ($nyckellista);
echo $count;
for($y=1; $y <= $count; $y++)
{
$countmore=count($nyckellista[$y]);
for($x=1; $x <= $countmore; $x++)
{
print ($nyckellista[$y][$x] . "<br> ");
}
echo "<br>";
}
我做錯了什麼?
嗨!我知道索引這是一個測試示例代碼.. 我想要它來保存我這樣的東西 $ nyckellista [我的所有密鑰數組] [該密鑰和帖子的元數據]我可以這樣做嗎? – 8bitcat 2012-03-10 21:26:59
好吧,不是直接的,你可以將鍵數組內嵌到一個字符串中,然後使用該字符串來索引數組 – msonsona 2012-03-10 22:18:37
這將看起來如何?並感謝您的回答;) – 8bitcat 2012-03-11 06:32:17