dongshuofu0039 2016-10-12 14:06
浏览 46
已采纳

创建多个单个帖子页面,每个页面上的滑块显示不同的类别

I have built out the below page in wordpress, single.php, with a custom slider on the top. Currently the slider is showing the posts from all categories with the post body showing the correct content.

What I need is 3 pages, single1.php, single2.php, and single3.php showing only the posts from category 1 on single1.php, category 2 on single2.php, and category 3 on single3.php.

<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>
  • 写回答

1条回答 默认 最新

  • douyan4243 2016-10-12 14:35
    关注

    You can do this by creating category templates. For example, if you have a category named "puzzle" then create a new php file in the theme called "category-puzzle.php" and only posts within that category will display.

    Hope this helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入