当没有帖子存在类别
获取Wordpress来显示消息我试图让我的博客在访问类别主页时向访问者显示消息(例如:www.website.com/category-slug-here/ ),但似乎无法弄清楚Wordpress循环非常正确。这是我开始在我的主题的的index.php文件:当没有帖子存在类别
get_header(); ?>
<div id="page-wrap" class="blog-page blog-fullwidth container">
<div id="content" class="blog-wrap <?php echo esc_attr($sidebarlayout); ?> columns">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part('framework/inc/post-format/entry', get_post_format()); ?>
<?php endwhile; endif; ?>
<?php get_template_part('framework/inc/nav'); ?>
</div>
<?php if($sidebar != 'no-sidebar'){ ?>
<div id="sidebar" class="<?php echo esc_attr($sidebarorientation); ?> alt">
<?php get_sidebar(); ?>
</div>
<?php } ?>
</div>
<?php get_footer(); ?>
这里是我如何试图改变它:
get_header(); ?>
<div id="page-wrap" class="blog-page blog-fullwidth container">
<div id="content" class="blog-wrap <?php echo esc_attr($sidebarlayout); ?> columns">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part('framework/inc/post-format/entry', get_post_format()); ?>
<?php endwhile; else: ?>
<p>Sorry, looks like this category is empty!</p>
<?php endif; ?>
<?php get_template_part('framework/inc/nav'); ?>
</div>
<?php if($sidebar != 'no-sidebar'){ ?>
<div id="sidebar" class="<?php echo esc_attr($sidebarorientation); ?> alt">
<?php get_sidebar(); ?>
</div>
<?php } ?>
</div>
<?php get_footer(); ?>
然而,使得这种变化似乎并没有产生任何结果。我在这里错过了什么吗?似乎这应该工作(但我也不是一个完整的PHP大师,这就是为什么我来这里咨询大众)。 ;)
在wordpress中类别的帖子显示在archive.php
页面。
尝试写在档案页面,而不会index.php
页
辉煌!谢谢你,@PrakashRao,为这个答案 - 完全帮助我,你是对的,这是我需要进行调整的archive.php页面,而不是index.php页面。感谢您的帮助! :D – fireboy63
欢迎亲爱的 –
看起来确定你有正确的文件的其他条件? – David