WordPress

条件分岐

'19.02.24

TOPページとその他ページの内容を分ける

<?php if ( is_home() || is_front_page() ) : ?>
TOPページに表示したい内容
<?php else : ?>
TOPページ以外に表示したい内容
<?php endif; ?>

 

親カテゴリで条件分岐

<?php $cat = get_the_category(); $parent_id = $cat[0]->category_parent;?>
<?php if (is_category(1)||$parent_id == 1):?>
  ここに処理を記述
<?php endif;?>

 

(View1222)