PS Disable Auto Formatting
WordPressによる、自動整形、タグ除去などを無効にするプラグイン
<?php
//子カテゴリ一覧を取得
$cat_child = get_term_children($category->cat_ID ,'category' );
//新規配列に表示させる親カテゴリと非表示の子カテゴリIDを追加
//非表示にするカテゴリはIDの前に「-」マイナスをつける
$args_cat = array($category->cat_ID );
foreach( $cat_child as $val){
$args_cat[] = '-'.$val;
}
$args = array(
'posts_per_page' => -1, // 全件取得
'category' => $args_cat, //現在のカテゴリ記事は表示し、子カテゴリを非表示
);
$cat_posts = get_posts($args);
if ( $cat_posts ) {
global $post;
foreach( $cat_posts as $post ) {
setup_postdata( $post );
?>
<a href="<?php the_permalink(); ?>"><i class="far fa-file-alt"></i> <?php the_title(); ?></a>
<?php
}//foreach
wp_reset_postdata();
}
?>
graffiti on the web
この投稿へのコメント
コメントはまだありません。