Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 404正在工作,而不是自定义博客模板_Wordpress_Http Status Code 404_Blogs - Fatal编程技术网

Wordpress 404正在工作,而不是自定义博客模板

Wordpress 404正在工作,而不是自定义博客模板,wordpress,http-status-code-404,blogs,Wordpress,Http Status Code 404,Blogs,我现在正在开发Wordpress模板。我有一个静态索引页。对于我的博客帖子,我使用名为blog的自定义模板。但是当我在这个博客模板下创建一个页面并尝试查看该页面时;它不显示博客页面,而是显示404.php 我正在使用这些文件: index.php //static index page blog.php //blog page under Blog template 404.php 这是我的网站 这是一个不起作用的博客页面 有关更多帮助,请参见我的blog.php主代码段:

我现在正在开发Wordpress模板。我有一个静态索引页。对于我的博客帖子,我使用名为
blog
的自定义模板。但是当我在这个
博客
模板下创建一个页面并尝试查看该页面时;它不显示博客页面,而是显示
404.php

我正在使用这些文件:

index.php //static index page
blog.php //blog page under Blog template
404.php
这是我的网站 这是一个不起作用的博客页面

有关更多帮助,请参见我的blog.php主代码段:

            <div class="single_post">
                <?php
                // The Query
                $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
                query_posts("paged=$page");
                // The Loop
                if(have_posts()) :
                while ( have_posts() ) : the_post();
                ?>
                <table>
                    <tr>
                        <td class="left_date">

                                <h1><?php the_time('d') ?></h1>
                                <p><?php the_time('M') ?></p>
                                <span class="year"><p><?php the_time('Y') ?></p></span>

                        </td>
                        <td>
                            <a href="<?php the_permalink(); ?>" ><h2><?php the_title(); ?></h2></a>
                            <div class="author_tag">
                                <span class="author">By: <?php the_author_posts_link(); ?></span>
                                <span class="tag"><?php the_tags(); ?></span>
                            </div>
                            <div class="post">
                                <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('post-image', array('class' => 'post-thumb')); ?></a>
                                <p><?php the_excerpt(); ?></p>
                                <div class="read_comment">
                                    <a href="<?php the_permalink(); ?>" title="Full post"><span class="read">Read more</span></a>
                                    <span class="comment"><?php comments_popup_link('No Comment', '1 Comment', '% Comments'); ?></span>
                                </div>
                            </div>
                        </td>
                    </tr>
                </table>
                <div class="clear"></div>
                <div class="gap"></div>
                <?php
                    endwhile; ?>
                    <table class="nav_post">
                        <tr>
                            <td><div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&laquo;</span> Previous posts') ); ?></div></td>
                            <td><div class="nav-next"><?php previous_posts_link( __( 'Next posts <span class="meta-nav">&raquo;</span>') ); ?></div></td>
                        </tr>
                    </table>
                    <?php
                    endif;
                    // Reset Query
                    wp_reset_query();
                ?>
            </div>

作者:


阅读本文,我认为您的问题在于,您应该调用模板page-blog.php,让它自动用作名为“blog”(可能是slug?)的页面的模板

参见此处的法典

WordPress模板层次结构还可以识别特定的页面或模板 自动发布,无需将其分配到特定页面 模板文件。如果模板文件名中包含ID或slug的页面 由用户创建,则相应的页面模板文件为 自动使用

page-{id}.php

page-{slug}.php


尝试在blog.php上添加模板代码,比如粘贴代码

<?php
/*
 * Template name: blog Template
 */
?>


之后,在你的管理中,你的博客页面编辑你的模板,你可以在编辑博客页面时在下拉列表中看到博客模板。希望这对您有用。

好的,首先检查是否是因为我的永久链接结构将您的永久链接更改为默认,然后查看是否发生了任何事情。您可以粘贴永久链接设置,并检查是否启用了“重写模块”。什么也没有发生。同样的404问题。有一件事,当我在它下面创建一个页面时,我还有一个名为Personal Travel的自定义模板。这页很好用@anstrangel0检查下面的答案是的,我使用了自定义模板名称“Blog”:(,现在工作正常。非常感谢。我使用自定义模板名称“Blog”:(,现在工作正常。非常感谢。