简体   繁体   English

WordPress类别重定向到index.php

[英]Wordpress categories redirecting to index.php

Hello and good day to all! 大家好,大家好!

I started developing a wordpress theme from scratch, and everything seemed to be going well so far. 我从头开始开发了一个wordpress主题,到目前为止一切似乎进展顺利。 But now I have a small problem. 但是现在我有一个小问题。 When I click on one of the Post categories in my default wp sidebar, I get redirected to index.php, despite the fact that the link is referencing the exact name of the category. 当我单击默认wp侧栏中的“帖子”类别之一时,尽管该链接引用了该类别的确切名称,但我仍被重定向到index.php。

How can I fix that, so when I click a category, I get the posts that are in that category? 如何解决该问题,因此,当我单击某个类别时,会收到该类别中的帖子?

My guess is that this must be a problem with my archive.php page or something like that. 我的猜测是我的archive.php页面或类似的东西一定有问题。 I am new to all of this, so please excuse my question. 我不熟悉所有这些,所以请原谅我的问题。

Big thanks in advance! 预先感谢!

So I managed to fix my problem thanks to anstrangel0ver's refference to the category.php file, which led me to http://bit.ly/1uMC6UC , but the code there has a little mistake that I just fixed, so here it is: 因此,由于anstrangel0ver对category.php文件的引用,我设法解决了问题,这使我进入了http://bit.ly/1uMC6UC ,但是那里的代码有一个我刚刚修复的小错误,所以这里是:

I must place this in category.php file in order for me to fix my issue: 我必须将其放在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>

NOTE: This is just a generic file structure, so it has to me modified according to Your needs. 注意:这只是一个通用文件结构,因此必须根据您的需要对其进行修改。

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

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