1
我很難實現這個到我的主題。現在主題只顯示最近的帖子。我知道如何顯示最近的帖子或頁面,但我不知道如何顯示它們。wordpress如何顯示最近更新的頁面和帖子
下面是電流回路代碼:
$nr_posts = ($sd_data['home_sidebar_hide'] == 1) ? $sd_data['home_news_posts_disabled'] : $sd_data['home_news_posts'] ;
$i = 0;
$args = array('post_type' => 'post',
'posts_per_page' => $nr_posts,
'order' => 'DESC',
'orderby' => 'date',
'post_status' => 'publish'
);
query_posts($args);
if(have_posts()) : while (have_posts()) : the_post(); $i++;
$margin_nr = ($sd_data['home_sidebar_hide'] == 1) ? 5 : 4;
if($i == 1) {
$class = 'span3 alpha';
} else if($i == $margin_nr) {
$i = 0;
$i++;
$class = 'span3 alpha';
} else $class = 'span3';
?>
<div class="<?php echo $class; ?>">
<div class="news-item">
<?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?>
<?php the_post_thumbnail('recent-blog'); ?>
<?php endif; ?>
<h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_title(); ?>
</a></h3>
<p><?php echo substr(get_the_excerpt(), 0, 50); ?>...</p>
<div class="news-meta clearfix"> <span class="news-date">
<?php the_time(get_option('date_format')); ?>
</span> <span class="news-comments">
<?php comments_popup_link('0', '1', '%', 'comments-link', 'c'); ?>
</span> <span class="news-rating"><?php echo sd_post_like_link(get_the_ID()); ?></span> </div>
</div>
</div>
<?php endwhile; wp_reset_query(); endif; ?>
謝謝!這正是我所期待的! –
歡呼!永遠不要忘記首先提及wordpress codex ..它是迄今爲止wordpress相關信息的最佳來源 – codepixlabs