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();
?>