如何在点击时显示特定的自定义帖子

时间:2018-11-27 05:41:09

标签: php wordpress customization

我想知道如何显示特定的自定义帖子-供您参考,我已经在wordpress仪表板面板中注册了自定义帖子类型,并且我还在根目录中创建了single-news.php文件,那么无论其帖子如何,所有步骤都已完成不可见,您能告诉我该怎么办吗?

 <?php
            // The Query
            $query = new WP_Query(array('post_type' => 'news', 'posts_per_page' => '1'));

            // The Loop
            if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>

                <div class="row">
                    <div class="col-md-6 post_img">
                        <?php the_post_thumbnail(); ?>
                    </div>
                    <div class="col-md-6 post_content">
                        <h2><?php the_title(); ?></h2>
                        <p><?php the_content(); ?></p>
                    </div>
                </div>



            <?php endwhile; endif; wp_reset_query(); ?>

0 个答案:

没有答案