Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.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类别重定向到index.php_Php_Wordpress - Fatal编程技术网

Wordpress类别重定向到index.php

Wordpress类别重定向到index.php,php,wordpress,Php,Wordpress,大家好,大家好 我从零开始开发wordpress主题,到目前为止一切似乎都进展顺利。但是现在我有一个小问题。当我点击默认wp侧栏中的一个帖子类别时,我会被重定向到index.php,尽管链接引用的是该类别的确切名称 我如何解决这个问题,所以当我点击一个类别时,我会得到该类别中的帖子 我猜这一定是我的archive.php页面或类似页面的问题。我对这一切都不熟悉,所以请原谅我的问题 非常感谢 由于anstrangel0ver对category.php文件的引用,我成功地解决了我的问题,这让我想到了

大家好,大家好

我从零开始开发wordpress主题,到目前为止一切似乎都进展顺利。但是现在我有一个小问题。当我点击默认wp侧栏中的一个帖子类别时,我会被重定向到index.php,尽管链接引用的是该类别的确切名称

我如何解决这个问题,所以当我点击一个类别时,我会得到该类别中的帖子

我猜这一定是我的archive.php页面或类似页面的问题。我对这一切都不熟悉,所以请原谅我的问题


非常感谢

由于anstrangel0ver对category.php文件的引用,我成功地解决了我的问题,这让我想到了,但是那里的代码有一个我刚刚修复的小错误,所以它是:

我必须将其放在category.php文件中,以便修复我的问题:

<?php
/**
* A Simple Category Template
*/

get_header(); ?>

<section id="primary" class="site-content">
    <div id="content" role="main">
        <?php // Check if there are any posts to display ?>
        <?php if ( have_posts() ) : ?>
            <?php while ( have_posts() ) : the_post(); ?>

            <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
            <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>

            <div class="entry">
                <?php the_excerpt(); ?>
                <p class="postmetadata"><?php comments_popup_link( 'No comments yet', '1 comment', '% comments', 'comments-link', 'Comments closed'); ?></p>
            </div>

        <?php endwhile; ?>
    <?php else: ?>
        <p>Sorry, no posts matched your criteria.</p>
    <?php endif; ?>
</div>

注意:这只是一个通用的文件结构,因此我必须根据您的需要对其进行修改。

您有archive.php模板吗?你的头版设置为什么?是的。My archive.php页面使用wordpress codex中的默认模板。我已经为它创建了一个页面,并将模板应用于它。但这似乎不起作用。我得到了一些零散的jibberish,比如无意义的搜索栏和每月分类,但这就是来自codex的默认archive.php模板中的全部内容。我怎样才能正确地修改它?使用category.php作为类别列表是的,我只是在下面的指南中添加了一个category.php>在那里我找到了wordpress查找类别输出的顺序:category-slug.php→ category-id.php→ category.php→ archive.php→ 但是他们提供的代码有一个错误,它给了我一个空白页面,上面写着:Parse error:syntax error,unexpected“该示例中的标记是错误的。您需要在whilehave_posts:the_post;之后添加?>closing PHP标记;。我相信你知道这个。。。