我製作了一個自定義模板,用於在單個頁面中顯示「產品」類別中的帖子。我有一些自定義字段。我需要在頁面中顯示自定義字段的值。我已經使用了get_post_custom_values爲以下但我得到一個錯誤get_post_custom_values無法正常工作
Warning: Invalid argument supplied for foreach() in C:\wamp\www\SampleSite\wp-content\themes\TwentyElevenChildTheme\products.php on line 11
爲products.php的代碼如下。
<?php
/*
Template Name: Product Template
*/
?>
<?php get_header(); ?>
<div id="content" class="narrowcolumn">
<?php $recent = new WP_Query("cat=4&showposts=10"); while($recent->have_posts()) :$recent->the_post();?>
<?php $key_values = get_post_custom_values("Description"); ?>
<?php foreach($key_values as $key => $value)?>
<?php echo "$key => $value("Description") <br />";?>
<?php endwhile; ?>
我沒有得到什麼錯誤is.Someone請在此