首页 > 解决方案 > 如何在点击时显示特定的自定义帖子

问题描述

我想知道如何显示特定的自定义帖子-为了您的信息,我已经在 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(); ?>

标签: phpwordpresscustomization

解决方案


推荐阅读