當我使用下面的代碼時,我在我的博客POSTS頁面上看到「數組」字樣。我有一種感覺,它涉及到這一行:博客文章頁面上出現字詞「數組」
我使用我的投資組合和新聞頁面類似的範本中的措辭是在這條線(「showportcat」和「shownewscat」,而不是「get_the_category略有不同「),它應該顯示類別,但相反,單詞'數組'是在它的位置。
我試過「showpostcat」,但沒有'工作,所以我想知道如果我需要重新措辭呢?或者,也許問題在於我在下面包含的代碼的另一部分?
<div class="greyblock">
<h4 class="nomar"><?php echo the_title(); ?></h4>
<div class="sep"></div>
<?php echo get_the_category(get_the_ID()); ?>
<div class="clear"></div>
<ul class="blogpost_list columns2">
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$args = array(
'post_type' => 'post',
'paged' => $paged,
'posts_per_page' => get_option("posts_per_page"),
);
if (isset($_GET['slug'])) {
$args['tax_query']=array(
array(
'taxonomy' => 'postcat',
'field' => 'slug',
'terms' => $_GET['slug']
)
);
}
$wp_query->query($args);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post();
#We have:
#get_permalink() - Full url to post;
#get_the_title() - Post title;
#get_the_content() - Post text;
#get_post_time('U', true) - unix timestamp
$featured_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail');
echo "
<li class='pc'>
<img alt='".get_the_title()."' src='".TIMTHUMBURL."?w=400&h=400&src=".$featured_image[0]."'>
<h4>".get_the_title()."</h4>";
$terms = get_the_terms($post->ID, 'postcat');
if ($terms && ! is_wp_error($terms)) {
$draught_links = array();
foreach ($terms as $term) {
$draught_links[] = $term->name;
}
$on_draught = join(", ", $draught_links);
}
echo "
<p>".get_the_excerpt()."</p>
<a href='".get_permalink()."' class='read'>Read more</a>
<br class='clear' />
</li>
";
endwhile; ?>
</ul>
</div>
<?php get_pagination() ?>
<?php $wp_query = null; $wp_query = $temp; ?>
'var_dump'變量,因此您可以看到您實際正在處理的內容。 – 2013-04-10 20:00:06