繁体   English   中英

为什么我的 WordPress 博文没有显示?

[英]Why are my WordPress blog posts not showing?

我正在开发带有博客页面的自定义 WP 主题。 博客页面正在显示帖子,但是当您单击每个帖子时,它会将您带到一个空白页面。

我已设置:设置 > 帖子页面 > 博客

基本上,博客页面显示所有内容,但 BLOG POST 页面为空白。 这是我的index.php


<div class="header-img-container container-fluid">
    <img 
    class="header-img" 
    role="banner" 
    src="http://cc.local/wp-content/uploads/2020/04/blog-page.jpg"  
    >
    <hr class="horizontal-line">

</div>

<div class="container">
    <div class="row">
            <div class="col">

                <div class="vertical-center">
                    <form action="http://cc.fullslate.com/">
                        <button class="appointment-button btn button">Schedule</button>
                    </form>
                </div>
                <p class="page-body-title">Blog</p>
                <div id="primary" class="content-area">
                    <main id="main" class="site-main">

                    <?php
                    if ( have_posts() ) {

                        // Load posts loop.
                        while ( have_posts() ) {
                            the_post();
                            get_template_part( 'template-parts/content/content' );
                        }

                        // Previous/next page navigation.
                        //cc_the_posts_navigation();

                    } else {

                        // If no content, include the "No posts found" template.
                        get_template_part( 'template-parts/content/content', 'none' );

                    }
                    ?>

                    </main><!-- .site-main -->
                </div><!-- .content-area -->
            </div>
    </div>
</div>

If you want to edit the view of a single post, you need to use the single.php Find out more about template hierarchy in wordpress: https://developer.wordpress.org/themes/basics/template-hierarchy/

它应该是这样的: https://developer.wordpress.org/themes/template-files-section/post-template-files/

您可以根据您的需要调整这个 single.php,它会因为其中的后循环而正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM