2012-09-26 92 views
0

我試圖在this page上顯示自定義縮略圖和標題的前5個帖子,我只需要顯示接下來5個帖子的標題,然後顯示分頁。你可以看到我需要的一個例子by clicking here。 (請參閱左側的帖子)關於Wordpress(PHP)的自定義博客頁面 - 分頁

以下是我在頁面上使用的自定義模板。

<?php 
get_header(); ?> 
<div id="primary"> 
<div id="content" role="main"> 

<?php 
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
query_posts($args); 
if(have_posts()) :?> 

<?php twentyeleven_content_nav('nav-above');?> 
<?php while (have_posts()) : the_post(); ?> 
      <div class="post-thumb-title"> 
      <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(array(632,305));?></a> 
      <p class="thumb-title2"><?php the_title(); ?></p> 
      <p class="news-date"><?php the_time('F jS, Y') ?></p> 
      <div id="post-excerpt"> 
      <?php the_excerpt(); ?> 
      </div> 
      </div> 
<?php endwhile; ?> 
<?php twentyeleven_content_nav('nav-below'); ?> 

<?php else : ?> 
<article id="post-0" class="post no-results not-found"> 
<header class="entry-header"> 
<h1 class="entry-title"><?php _e('Nothing Found', 'twentyeleven'); ?></h1> 
</header><!-- .entry-header --> 

<div class="entry-content"> 
<p><?php _e('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven'); ?></p> 
<?php get_search_form(); ?> 
</div> 
<?php endif; ?> 
</div> 
</div> 
<?php get_sidebar(); ?> 
<?php get_footer(); ?> 

感謝

回答

0

你可以嘗試這樣的事情

<?php 
// amount of posts shown with thumbnail 
// post 6 .. pagesize (wp-admin > settings > reading) will be displayed as link only 
$withThumb = 5; 
while (have_posts()) : the_post(); 
    if ($withThumb-- > 0) { ?> 
     <div class="post-thumb-title"> 
      <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(array(632,305));?></a> 
      <p class="thumb-title2"><?php the_title(); ?></p> 
      <p class="news-date"><?php the_time('F jS, Y') ?></p> 
      <div id="post-excerpt"> 
       <?php the_excerpt(); ?> 
      </div> 
     </div> 
    <?php } else { ?> 
     <div class="post-title"> 
      <p class="thumb-title2"> 
       <a href="<?php the_permalink() ?>"><?php the_title(); ?></a> 
      </p> 
     </div> 
    <?php } ?> 
<?php endwhile; ?> 
+0

這是打破我的網頁。沒有運氣。 –

+0

可能,沒有測試它,但得到了任何錯誤消息/警告? –

+0

沒有。只是一個空白的頁面。我確定我正確地替換了我的代碼,因爲我檢查了兩次。 –