HighLab

SEO対策 wordpress

  • 公開日:
  • 更新日:
  • 文字数:4334文字
<?php //header.php にコピーしてください。?>

<?php include("inc/inc-head.php"); ?>

<?php

  $site_name = '株式';
  $title = '株式';
  $desc = 'きます';
  $key_word = 'キーわど';
  /*OGP 1200x620 png推奨*/
  $ogp_img = '/img/com/ogp.png';
  $key_word = '';
  /*32x32 png*/
  $icon_path = '/img/com/favo.png';
  $author = '';
  $site_url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$site_url = str_replace('http://', 'https://', $site_url); /*facebook app*/ $fbapp_id = ''; ?> <?php if (is_home() || is_front_page()): ?> <?php $site_name =''; $title = ''; $desc = ''; ?> <?php elseif (is_404('')): ?>
<?php $title = '404ページ';;?>
<?php $desc = 'URLが正しく入力されていないか、このページが削除された可能性があります。';?> <?php elseif (is_page()): ?> <?php while (have_posts()) : the_post(); ?> <?php $title = the_title( '', '', false );?> <?php $title = get_field('pagetitle'); ?> <?php $desc = get_the_content(); $desc= str_replace("<!-- wp:paragraph -->","",$desc); $desc= str_replace("<!-- /wp:paragraph -->","",$desc); $desc= str_replace("<br>","",$desc); $desc= str_replace("<p>","",$desc); $desc= str_replace("</p>","",$desc); $desc = str_replace(array("\r\n", "\r", "\n"), '', $desc); $desc= strip_tags($desc); if(mb_strlen($desc, 'UTF-8')>150){ $desc= mb_substr($desc, 0, 150, 'UTF-8'); } ?> <?php endwhile; ?> <?php elseif (is_archive()): ?> <?php $cats = get_the_category(); ?> <?php /* アーカイブページ */ ?> <?php foreach($cats as $cat): ?> <?php $title = $cat->cat_name . '一覧';?> <?php endforeach; ?> <?php $desc = $site_name.'の'.$cat->cat_name.'ページです。';?> <?php elseif(is_single()): ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $title = the_title( '', '', false );?> <?php $desc = get_the_content(); $desc= str_replace("<!-- wp:paragraph -->","",$desc); $desc= str_replace("<!-- /wp:paragraph -->","",$desc); $desc= str_replace("<br>","",$desc); $desc= str_replace("<p>","",$desc); $desc= str_replace("</p>","",$desc); $desc = str_replace(array("\r\n", "\r", "\n"), '', $desc); $desc= strip_tags($desc); if(mb_strlen($desc, 'UTF-8')>150){ $desc= mb_substr($desc, 0, 150, 'UTF-8'); } ?> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <?php endif; ?> <title><?php echo $title;?> | <?php echo $site_name;?></title> <meta name="description" content="<?php echo $desc;?>" /> <meta name="keywords" content="<?php echo $key_word;?>" /> <meta name="author" content="<?php echo $author;?>"> <link rel="shortcut icon" href="<?php echo get_template_directory_uri();?><?php echo $icon_path;?>"> <meta property="og:locale" content="ja_JP" /> <meta property="og:type" content="website" /> <meta property="og:title" content="<?php echo $title;?> | <?php echo $site_name;?>" /> <meta property="og:description" content="<?php echo $title;?> | <?php echo $site_name;?>" /> <meta property="og:url" content="<?php echo $site_url;?>" /> <meta property="og:site_name" content="<?php echo $title;?> | <?php echo $site_name;?>" /> <meta property="og:image" content="<?php echo get_template_directory_uri();?><?php echo $ogp_img;?>" /> <meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:description" content="<?php echo $desc;?>" /> <meta name="twitter:title" content="<?php echo $title;?> | <?php echo $site_name;?>" /> <meta name="twitter:site" content="<?php echo $site_url;?>" /> <meta property="fb:app_id" content="<?php echo $fbapp_id; ?>" /> <?php if (!is_404()): ?>
<link rel="canonical" href="<?php echo $site_url;?>" />
<?php endif; ?> <!-- Global site tag (gtag.js) - Google Analytics --> <!-- User Heat Tag --> <!-- End User Heat Tag -->