Wordpress类别重定向到index.php

时间:2014-12-16 09:05:40

标签: php wordpress

大家好,祝大家好!

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

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

我的猜测是,这对我的archive.php页面或类似的问题一定是个问题。我是所有这一切的新手,所以请原谅我的问题。

提前非常感谢!

1 个答案:

答案 0 :(得分:0)

所以我设法解决了我的问题,感谢anstrangel0ver对category.php文件的引用,这导致我http://bit.ly/1uMC6UC,但那里的代码有一点我刚刚修复的错误,所以这里它是:

我必须将它放在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>

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