0
我需要使用类别名称作为H1的类,并且还需要排除类别2.所以我将下面的PHP代码拼凑在一起。它工作正常,除了文章丢失格式。我知道get_post_format()
是什么格式的应用,但是当我添加它时,它似乎没有做任何事情。任何帮助将不胜感激,谢谢。获取文章格式
<?php while (have_posts()) : the_post();
$excludedcats = array(2);
$count = 0;
$categories = get_the_category();
foreach($categories as $category)
{
$count++;
if (!in_array($category->cat_ID, $excludedcats))
{
echo '<h1 class="category-heading ' . sprintf(__("heading-%s"), $category->slug) . '" >';
if($count != count($categories))
{
echo " ";
}
}
}
single_post_title();
echo '</h1>';
the_content();
?>