0
我想在wordpress中從1個類別拉1個帖子,但如果不是它應該顯示自定義帖子類型I打電話。例如推薦書,最新消息,案例研究。顯示1個帖子從一個特定的catergory如果在wordpress中選擇
這是我的,我需要一個ifelse;語句來查詢貓是否不存在,然後在該CPT中顯示最新帖子。
這是我的代碼。
<?php
$query = new WP_Query('post_type=testimonial&catergory_name=home&showposts=1&paged=' . $paged);
$postcount = 0;
?>
<?php if ($query->have_posts()) : ?>
<?php while ($query->have_posts()) : $query->the_post(); ?>
<?php $postcount++; ?>
<li>
<A HREF="<?php the_permalink(); ?>"></A>
<a href="<?php the_permalink(); ?>">
<?php
if (has_post_thumbnail()) {
// check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail('thumb-casestudy');
}else {
?>
<img src="<?php bloginfo('template_url'); ?>/assets/images/default.jpg" alt="<?php the_title(); ?>"/>
<?php } ?>
</a>
<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<p class="hm_text"><?php
//the_excerpt();
echo get_post_meta($query->post->ID, 'wpld_cf_home_page_text', true)
?></p>
</li>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
請再次寫一遍你想做什麼。 – 2013-04-23 20:11:23