2016-07-15 97 views
0

在我的新WordPress主題中,我爲博客文章做了一個靜態的首頁和一個子頁面,但問題是帖子不顯示。如果我在沒有靜態首頁的情況下使用它,帖子顯示正常。什麼可能是錯的?不顯示的WordPress的帖子

這裏是我的博客頁面代碼:

<?php 

/* 
Template Name: Blog page  
*/ 

get_header(); 
?> 

<!--parallax section 1--> 
<div class="section-one"> 
    <div class="parallax-section-1"> 
    </div> 
    <div class="container-fluid"> 
     <h1>News</h1> 
    </div> 
</div> 

<div class="container-fluid"> 

     <?php if(have_posts()) : while (have_posts()) : the_post(); ?> 

      <div class="post"> 
       <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> 
       <h6>Posted on <?php the_time('F jS, Y'); ?> by <?php the_author_posts_link(); ?></h6> 

       <div class ="entry"> 
        <?php the_content(); ?> 
       </div> 
      </div> 

     <?php 
      endwhile; 
      else: 
     ?> 
      <p> Sorry, no posts to display.</p> 
     <?php endif; ?> 

</div> 

<?php get_footer(); ?> 
+0

你設置的頁面設置下的文章頁>閱讀? – Peter

+0

是的,我做到了。頁面顯示,除了帖子以外的所有內容 – mheonyae

+0

嘗試刪除if並且只是有一段時間。所以它應該以<?php開頭,while(has_posts()):the_post(); ?>,並以<?php結尾; ?> – Peter

回答

0

之前加上「如果」

$args=array(
    'post_status' => 'publish', 
    'posts_per_page' => 4, 
    'order' => 'ASC' 
       ); 
$my_query = new WP_Query($args);