我的问题:
如果我浏览到
http://mysite/category/mycategory
, 这个
if (is_category())
未显示内容,
the if(is_archive())
is shown instead.我的代码:
archive.php
:
<?php include(\'includes/resultlist.php\')?>
search.php
:
<?php include(\'includes/resultlist.php\')?>
includes/resultlist.php
:
<?php get_header(); ?>
<div class="main">
<?php if (is_archive()) { ?>
<h1>Artigos publicados em <?php single_month_title(\' \'); ?></h1>
<?php } else if (is_search()) { ?>
<h1>Resultados para "<?php the_search_query(); ?>"</h1>
<?php } else if (is_category()) { ?>
<h1>Resultados para categoria "<?php the_category(); ?>"</h1>
<?php }
if ( have_posts() ) while (have_posts()) { the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
por <span class="date"><?php the_author(); ?></span> em
<span class="date"><?php the_date(); ?></span>
<p><?php echo get_the_excerpt(); ?> <a href="<?php the_permalink(); ?>">Leia mais</a></p>
<?php }
else {?>
<h2>Nada encontrado</h2>
<p>Desculpe, não encontramos o que você procurava!</p>
<?php }
include(\'pagination.php\');
?>
</div><!-- /main -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
我尝试的内容:创建了
category.php
包含以下内容的文件:
<?php include(\'includes/resultlist.php\')?>
但问题仍然存在。我在分类的末尾添加了一些垃圾文本。php,它显示在呈现页面的末尾,因此我想正在调用该文件。
我的环境:
LAMP Ubuntu 64位,安装apache、mysql和php,通过apt get使用默认选项。