<?php
the_post();
$page_title = get_the_title();
$thisContent = get_the_content();
$page_description = str_replace(PHP_EOL, "", mb_strimwidth(strip_tags($thisContent), 0, 350, "..."));

$ogImage = "";
$thumbnail_id = get_post_thumbnail_id($post->ID);
$hasThumbnail = wp_get_attachment_image_src($thumbnail_id, "full");
if ($hasThumbnail) {
	$ogImage = $hasThumbnail[0];
}
if (!$hasThumbnail) {
	$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $thisContent, $matches);
	$ogImage = $matches[1][0] ?? null;
}
if (!$ogImage) {
	$ogImage = "https://taihei-sp.com/topics/wp-content/themes/taiheiwp/img/og_image.png";
}
//$category = get_the_category();
//$cat = $category[0];
//カテゴリー名
//$cat_name = $cat->name;
//カテゴリースラッグ
//$cat_slug = $cat->slug;
get_header();
?>
<div class="imgArea">
</div>
<div class="breadArea02">
  <ul class="inner">
    <li><a href="<?php echo home_url('/'); ?>">TOP</a></li>
	<li><a href="<?php echo home_url('/topics/'); ?>">最新情報</a></li>
	<li><?php echo mb_strimwidth($page_title, 0, 20, "..."); ?></li>
    </ul>
</div>
<div class="ttlArea">
  <div class="inner">
    <div class="h1Area news">
      <div class="title">お知らせ</div>
    </div>
  </div>
</div>
<section>
	<div class="singleArea">
		<div class="inner">
			<!--<div class="categoryArea">
				<ul>
					<li class="icon <?php echo $cat_slug; ?>"><?php echo $cat_name; ?></li>
				</ul>
			</div>-->
			<div class="single">
				<div class="ttlArea">
					<time class="date"><?php the_time("Y.m.d"); ?></time>
					<h1 class="ttl"><?php echo get_the_title(); ?></h1>
				</div>
				<div class="txt">
					<?php the_content(); ?>
				</div>
				<div class="pager pager-single">
					<ul>
						<?php previous_post_link("<li class=\"prearrow arrow\">%link</li>", "前の記事へ"); ?>
						<?php next_post_link("<li class=\"nextarrow arrow\">%link</li>", "次の記事へ"); ?>
					</ul>
				</div>
			</div>
		</div>
	</div>
	</div>
</section>
<?php get_footer(); ?>