这是我的网站,我们正在为班级改造一个非营利组织的网站(它与实际组织没有关联)。在此页面上:https://dev-hopeproject.pantheonsite.io/news/ 应该有一个循环来显示特定类别的内容;新闻“;,ID为3。
这是新闻提要。php:
$posts = query_posts($query_string.\'&cat=3\'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1><?php the_title();?></h1>
<p><?php the_content();?></p>
<?php
endwhile;
endif; ?>
</div>
它由索引调用。如果有其他情况,请使用以下php:<?php
if (is_page( \'home\' ) ):
include(\'loop.php\');
include(\'buttons.php\');
include(\'recent-articles.php\');
elseif (is_page(\'news\')):
include(\'newsfeed.php\');
dynamic_sidebar(\'home_right_1\');
endif;
?>
<!-- <?php get_sidebar(); ?> -->
<?php get_footer(); ?>
奇怪的是,虽然这与我在主页上最近的文章中所做的几乎相同。php,<div id="aboutwrap"><?php global $query_string;
$posts = query_posts($query_string.\'&cat=2\'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1><?php the_title();?></h1>
<?php the_content();
endwhile;
endif; ?>
</div>
新闻源的内容未出现。事实上it\'s specifically displaying the title of the page, "News", rather than the title of the only post in that category, which is "Covid Updates".我的教授可能是对的,所有这些循环都让网站变得一团糟,但为什么两个几乎相同的循环在同一个网站上不起作用,这让我很苦恼。有什么想法吗?