2012-04-12 26 views
0

現在我已經做了幾次其他時間沒有問題,我有一個主頁使用home.php和博客作爲另一個頁面使用「blog-home.php」博客模板與所有正確的代碼來抓取帖子但不顯示。唯一的區別是我爲這些函數添加了一個自定義投資組合職位字段,這是否會影響它,或者它可能是其他內容?我可以在主頁下的最新帖子中查看帖子,將代碼放在下面,但就是這樣。WordPress博客不顯示帖子。是否添加一個自定義投資組合後場效應呢?

<?php query_posts("post_per_page=1"); the_post(); ?> 
    <p><?php the_excerpt(); ?></p> 
    <?php wp_reset_query(); ?></div> 

* 更新:我已經嘗試另一個代碼,但現在它只是顯示了博客頁面的職位。 *

<?php 

/* 
    Template Name: Blog Home 
*/ 
?> 
<?php get_header(); ?> 
<div id="contentwrapper"> 
<?php query_posts(array ('category_name' => 'Blog', 'posts_per_page' => 5 )); ?> 
     <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
      <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> 
       <div class="blogentry"> 
       <h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a> </h4> 
       <?php the_content(); ?> 
        <div class="postmetadata"> 
         <?php the_tags('Tags: ', ', ', '<br />'); ?> 
        </div> 
       <?php include (TEMPLATEPATH . '/inc/meta.php'); ?> 
       </div> 

      </div> 

      <?php endwhile; ?> 

      <?php include (TEMPLATEPATH . '/inc/nav.php'); ?> 

      <?php else : ?> 

      <h2>Not Found</h2> 

      <?php endif; ?> 


</div> 



<?php get_footer(); ?> 
+0

它似乎不是一個自定義字段會阻止帖子,但你有鏈接博客家模板到頁面? – rncrtr 2012-04-12 21:49:28

+0

是的,我已經使用我的代碼編輯了我的所有其他網站的代碼。 – 2012-04-12 22:04:02

回答

0

也許如果你使用

$posts = get_posts(array('numberposts' => 1)); 
global $post; 
$post = $posts[0]; 
the_excerpt(); 

代替

query_posts(); 

從來都不是一個好主意,改變全球的查詢,如果get_posts不到風度對你的工作與WP_Query嘗試()

相關問題