2017-06-19 126 views
0

我的問題是,由於某些原因頁面標題和內容打印顛倒。它會打印搜索欄兩次。你可以看看coede bwlowWordpress不打印正確的內容

<?php get_header(); ?> 

<div class="row"> 

    <div class="col-xs-12 col-sm-8"> 

     <div class="row text-center no-margin"> 

     <?php 
     $currentPage = (get_query_var('paged')) ? get_query_var('paged') : 1; 
     $args = array('posts_per_page' => 3,'post_type'=>'post', 'paged' => $currentPage); 
     new WP_Query($args); 
     if(have_posts()): $i = 0; 

      while(have_posts()): the_post(); ?> 

       <?php 
        if($i==0): $column = 12; $class = ''; 
        elseif($i > 0 && $i <= 2): $column = 6; $class = ' second-row-padding'; 
        elseif($i > 2): $column = 4; $class = ' third-row-padding'; 
        endif; 

       ?> 
        <?php the_content(); ?> 

        <div class="col-xs-<?php echo $column; echo $class; ?> blog-item"> 
         <?php if(has_post_thumbnail()): 
          $urlImg = wp_get_attachment_url(get_post_thumbnail_id(get_the_ID())); 
         endif; ?> 
         <div class="blog-element" style="background-image: url(<?php echo $urlImg; ?>);"> 

          <!--<?php the_title(sprintf('<h1 class="entry-title"><a href="%s">', esc_url(get_permalink())),'</a></h1>'); ?> --> 
          <h1 class="entry-title"><?php the_title(); ?></h1> 

          <small><?php the_category(' '); ?></small> 
         </div> 
        </div> 

      <?php $i++; endwhile; ?> 

      <div class="col-xs-6 text-left"> 
       <?php next_posts_link('« Older Posts'); ?> 
      </div> 
      <div class="col-xs-6 text-right"> 
       <?php previous_posts_link('Newer Posts »'); ?> 
      </div> 

     <?php endif; 
       wp_reset_query(); 
     ?> 
     </div> 

    </div> 

    <div class="col-xs-12 col-sm-4"> 
     <?php get_sidebar(); ?> 
    </div> 

</div> 

<?php get_footer(); ?> 

回答

1

也許你在做YouTube的Wordpress101課程。在你顯示的代碼中沒有搜索欄。搜索欄是在您使用此處稱爲標題:

也許在頭重複調用到搜索表單:

 <div class="container"> 
      <?php get_search_form(); ?> 
     </div> 

另外,我有這樣的自舉不渲染問題這是菜單的一個很好的方法,所以我必須在header.php中添加(不管我是否也參考了functions.php文件中的引導程序,正如我在教程中所做的那樣)引導程序中的行數CDN本頁內容: http://blog.getbootstrap.com/2016/07/25/bootstrap-3-3-7-released/

複製此CDN l油墨:

  • 最新的編譯和精縮CSS
  • 可選主題
  • 最新的編譯和精縮的JavaScript