我创建了一个名为news的自定义帖子类型并添加了某些新闻。现在我想将它显示在存档页面中。我在函数文件中添加了'has_archive'=>'true'。 我的档案页面的代码是:自定义帖子类型的存档页面
<?php
$args = array('post_type' => 'news',
'post_status' => 'publish');
$news=wp_get_recent_posts($args);
?>
<div class="container mc_tb_p">
<h1>NEWS/RELEASES</h1>
<?php
foreach ($news as $row)
{
$id = $row['ID'];
$ntitle = $row['post_title'];
$ncontent = $row['post_content'];
$ncontent = strip_tags($ncontent);
if (strlen($ncontent) > 100)
{
$stringCut = substr($ncontent, 0, 200).'... <a href="'.get_permalink($id).'">Read More</a>';
}
else{
$stringCut = $row['post_content'];
}
$ndate = $row['post_date'];
$trim = new DateTime($ndate);
$trimdate = $trim->format('d-m-Y');
// var_dump($trimdate);
?>
<div class="news_releases">
<a href="<?php echo get_permalink($id)?>"><h3><?php echo $ntitle?></h3></a>
<h5><i>Published On: <?php echo $trimdate?></i></h5>
<p><?php echo $stringCut;?></p>
</div>
<?php
}
?>
</div>
现在,当我给我的网址:https //站点名称/新闻...它造就了第二个消息,并没有别的单页,我已经尝试了一切,但没有似乎work.Please帮助
我试图做到这一点,但它没有按照它应该的方式工作!存在同样的问题。我正在使用可选框架主题硕士..它是sumthng与它有关 – Jackson
我甚至从列表中删除了存档页面,仍然一边去我的网址/新闻它直接提出了我的第二条新闻的单页! – Jackson
你可以检查阵列和自定义帖子类型中的所有slu and和名字吗? –