File "taxonomy-construction-cat.php"
Full path: /home/xs854402/smcse.co.jp/public_html/wp-content/themes/Sumitomo-Mitsui/taxonomy-construction-cat.php
File
size: 7.92 B (7.92 KB bytes)
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php get_header(); ?>
<main class="corporate">
<?php include('template/bottom-corporate-construction-cat.php'); ?>
<?php include('template/breadcrumb.php'); ?>
<section class="p-products">
<div class="p-products__heading">
<div class="p-products__inner l-inner">
<?php
$object = get_queried_object();
$name = $object->name;
if($name == '橋梁事業') {
$id = 892;
} elseif($name == '橋梁保全事業') {
$id = 896;
} elseif($name == '沿岸事業') {
$id = 898;
} elseif($name == 'その他事業') {
$id = 897;
} else {
$id = 526;
}
?>
<?php
if (have_rows('construction-lead', $id)) :
while (have_rows('construction-lead', $id)) : the_row();
?>
<h2 class="p-products__theme"><?php the_sub_field('construction-lead-title'); ?></h2>
<p class="p-products__description c-text"><?php the_sub_field('construction-lead-text'); ?></p>
<?php
endwhile;
endif;
?>
<?php
$target_post = 'construction';
$target_post_cat = $taxonomy;
$target_cat_slug = esc_html($object -> slug);
$target_cat_name = esc_html($object -> name);
$child_cats = get_terms($target_post_cat,'hierarchical=0&hide_empty=1&parent='.$object -> term_id);
if( $child_cats ) :
foreach( $child_cats as $child_cat ):
$child_cat_name = esc_html($child_cat -> name);
$target_cat_slug = esc_html($child_cat->slug);
?>
<div class="p-products__childBlock">
<h3 class="p-post__theme"><?php echo $child_cat_name; ?>実績</h3>
<?php
$grand_child_cats = get_terms($target_post_cat,'hierarchical=0&hide_empty=1&parent='.$child_cat -> term_id);
if( $grand_child_cats ) :
?>
<div class="p-products__items">
<?php
foreach( $grand_child_cats as $grand_child_cat ):
$grand_child_cat_name = esc_html($grand_child_cat -> name);
$target_grand_cat_slug = esc_html($grand_child_cat->slug);
?>
<div id="track-<?php echo $target_grand_cat_slug; ?>" class="p-products__item p-record">
<p class="p-record__theme"><?php echo $grand_child_cat_name; ?></p>
<div class="p-record__body">
<?php
$id = esc_html($grand_child_cat->term_id);
$acf_row_image = get_field('term-thumbnail', 'construction-cat_'.$id);
$url = $acf_row_image['url'];
$alt = $acf_row_image['alt'];
if ($url) :
?>
<div class="p-record__img c-img">
<img src="<?php echo $url; ?>" alt="<?php echo $alt; ?>">
</div>
<?php endif; ?>
<div class="p-record__wrap">
<p class="p-record__text"><?php echo esc_html($grand_child_cat->description); ?></p>
<?php
$args = array(
'post_type' => array($target_post),
'taxonomy' => $target_post_cat,
'term' => $target_grand_cat_slug,
'post_status' => 'publish',
'posts_per_page' => -1, // 表示するページ数
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) :
?>
<div class="p-record__posts">
<?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
<a href="<?php the_permalink(); ?>" class="p-record__post"><?php the_title(); ?></a>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
<?php
endif;
wp_reset_postdata();
?>
</div>
</div>
<div class="p-business__related p-business__related--other">
<div class="p-business__inner l-inner">
<p class="p-business__entitle c-entitle c-entitle--capitalize">see other businesses</p>
<h2 class="p-business__title c-title">他の事業を見る</h2>
<div class="p-business__relatedItems">
<?php
$target_post = 'construction';
$target_post_cat = 'construction-cat';
$post_count = -1;
$cat_args = array(
'parent' => 0, //トップレベルのタームのみ
'hierarchical' => 0 //子タームを含めない
);
$cats = get_terms($target_post_cat, $cat_args);
foreach( $cats as $cat ):
$target_cat_slug = esc_html($cat -> slug);
$target_cat_name = esc_html($cat -> name);
if(!($cat->name == $object->name)) :
?>
<a href="<?php echo esc_url(home_url('/construction-cat/'.$cat->slug)); ?>" class="p-business__relatedItem p-relatedItem">
<?php
$acf_row_image = get_field('term-thumbnail', 'construction-cat_'.$cat->term_id);
$url = $acf_row_image['url'];
$alt = $acf_row_image['alt'];
if ($url) :
?>
<div class="p-relatedItem__img c-img">
<img src="<?php echo $url; ?>" alt="<?php echo $alt; ?>">
</div>
<?php endif; ?>
<p class="p-relatedItem__title"><?php echo $cat->name; ?></p>
</a>
<?php
endif;
endforeach;
?>
</div>
</div>
</div>
<?php include('template/others.php'); ?>
</section>
</main>
<?php get_footer();