2016-10-12 48 views
0

我已經在wordpress中使用single.php構建了下面的頁面,頂部有一個自定義滑塊。目前,滑塊顯示來自所有類別的帖子,帖子正文顯示正確的內容。創建多個不同類別的頁面在每個頁面上顯示不同的滑塊

我需要的是3頁,single1.php,single2.php和single3.php,其中只顯示來自single1.php的類別1,來自single2.php的類別2,來自single3.php的類別3。

<div class="row"> 
<div class="col-md-12 col-xs-12"> 
<div id="primary" class="content-area"> 
    <main id="main" class="site-main" role="main"> 
     <div class="cap-cont"> 
       <div class="cap">CHOOSE A AUTHOR</div> 
       <div class="auth-slide"> 
      <?php 

$loop = new WP_Query(array('post_type' => 'post', 'posts_per_page' => 30, 'post_status' => 'publish', 'orderby' => 'rand')); 
while ($loop->have_posts()) : $loop->the_post(); 
    $content .= '<div><a href="'; 
    $content .= get_permalink(); 
    $content .= '">'; 
    $content .= get_the_post_thumbnail(); 
    $content .= '</a></div>'; 
endwhile; 
echo $content; 

      ?> 
     </div>   

     </div>   
     <div class="y-dot"> 
      <img src="/wp-content/uploads/2016/09/Orange-Dotted-Line.png"> 
     </div> 
     <div class="info-cont"> 
      <div class="text"> 
       <div class="name"> 
        <?php the_field('name'); ?> 
       </div> 
       <div class="lname"> 
        <?php the_field('lname'); ?> 
       </div> 
       <div class="spec"> 
        <?php the_field('spec'); ?> 
       </div> 
       <div class="m-quote"> 
        <?php the_field('main_quote'); ?> 
       </div> 
       <div class="gtk"> 
        GET TO KNOW YOUR AUTHOR 
       </div> 
       <div class="quote"> 
        <p class="ques"> 
         <?php the_field('qus_one'); ?> 
        </p> 
        <p class="answ"> 
         <?php the_field('ans_one'); ?> 
        </p> 
        <p class="ques"> 
         <?php the_field('qus_two'); ?> 
        </p> 
        <p class="answ"> 
         <?php the_field('ans_two'); ?> 
        </p> 
        <p class="ques"> 
         <?php the_field('qus_three'); ?> 
        </p> 
        <p class="answ"> 
         <?php the_field('ans_three'); ?> 
        </p> 
       </div> 
      </div> 
      <div class="pic-cont"> 
       <div class="call"> 
        <strong>CALL (555) 555-5555</strong> 
       </div> 


       <div class="pic"> 
        <img src="<?php the_field('authimg'); ?>" alt=""/> 
       </div> 
      </div> 

     </div> 
     <div class="bsbhby"> 
       <img src="/wp-content/uploads/2016/09/Footer_25.png"> 
      </div> 

    </main><!-- #main --> 
</div><!-- #primary --> 
</div><!--col-md-12 col-xs-12 --> 
</div> 

回答

0

您可以通過創建分類模板來實現。例如,如果您有一個名爲「拼圖」的類別,則在名爲「category-puzzle.php」的主題中創建一個新的php文件,並且僅顯示該類別內的帖子。

希望這會有所幫助。

+0

完美的解決了我的問題,我只需要弄清楚如何根據選擇的帖子過濾滑塊中的類別,但我會爲此做出不同的選擇。 – Ryeboflaven

相關問題