今までの主な変更内容を記憶限り以下にまとめます。
ご参考下さい。
※作業は必ず、バックアップを取って行ってください。
※あと、作業は必ず、バックアップを取って行ってください。
※そして、作業は必ず、バックアップを取って行ってください。
functions.phpは、変更に失敗すると「真っ白」になったりします。
その時の対応がわからない方は、もう触らないか新しいテーマをご利用下さいませ。
あと、おかしくなってもサポートに手が回る保証はございません。。
タイトルの書き出し
タイトルの書き出しで、記事ページのタイトルに「ブログ名」を出すのをやめました。
下記のコードは1016の最新verになります。
header.phpのtitle内を変更して下さい。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<title> <?php global $page, $paged; if(is_front_page()): bloginfo('name'); elseif(is_single()): wp_title(''); elseif(is_page()): wp_title(''); elseif(is_archive()): wp_title('|',true,'right'); bloginfo('name'); elseif(is_search()): wp_title('-',true,'right'); elseif(is_404()): echo'404 - '; bloginfo('name'); endif; if($paged >= 2 || $page >= 2): echo'-'.sprintf('%sページ', max($paged,$page)); endif; ?> </title> |
但し、ブログがブランディングされていたり、テーマに統一性がある場合はあえて変更する必要もないと思います。
「ブログ名あり」はこちら
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<title> <?php global $page, $paged; if(is_front_page()): elseif(is_single()): wp_title('-',true,'right'); elseif(is_page()): wp_title('-',true,'right'); elseif(is_archive()): wp_title('-',true,'right'); elseif(is_search()): wp_title('-',true,'right'); elseif(is_404()): echo'404 -'; endif; bloginfo('name'); if($paged >= 2 || $page >= 2): echo'-'.sprintf('%sページ', max($paged,$page)); endif; ?> </title> |
ページナビを修正しました。
single.phpの下の方
1 2 3 4 5 6 7 8 9 |
<!--ページナビ--> <div class="p-navi"> <p> PREV : <?php previous_post_link('%link', '%title', TRUE, ''); ?> <br/> NEXT : <?php next_post_link('%link', '%title', TRUE, ''); ?> </p> </div> |
を
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<!--ページナビ--> <div class="p-navi clearfix"> <dl> <?php $prev_post = get_previous_post(); if (!empty( $prev_post )): ?> <dt>PREV </dt><dd><a href="<?php echo get_permalink( $prev_post->ID ); ?>"><?php echo $prev_post->post_title; ?></a></dd> <?php endif; ?> <?php $next_post = get_next_post(); if (!empty( $next_post )): ?> <dt>NEXT </dt><dd><a href="<?php echo get_permalink( $next_post->ID ); ?>"><?php echo $next_post->post_title; ?></a></dd> <?php endif; ?> </dl> </div> |
に変更。
style.css及びsmart.cssに以下を追記
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
/*--------------------------------- PREV NEXT --------------------------------*/ .p-navi dl dt { font-weight: bold; font-size: 15px; line-height: 27px; float: left; width: 50px; } .p-navi dl dd { font-size: 15px; padding-left: 55px; line-height: 27px; } |
固定ページのパンくずの変更
もしpage.phpのぱんくずが
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<div class="kuzu"> <div id="breadcrumb"> <div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> <a href="<?php echo home_url(); ?>" itemprop="url"> <span itemprop="title">ホーム</span> </a> > </div> <?php $postcat = get_the_category(); ?> <?php $catid = $postcat[0]->cat_ID; ?> <?php $allcats = array($catid); ?> <?php while(!$catid==0) { $mycat = get_category($catid); $catid = $mycat->parent; array_push($allcats, $catid); } array_pop($allcats); $allcats = array_reverse($allcats); ?> <?php foreach($allcats as $catid): ?> <div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> <a href="<?php echo get_category_link($catid); ?>" itemprop="url"> <span itemprop="title"><?php echo get_cat_name($catid); ?></span> </a> > </div> <?php endforeach; ?> </div> </div> <!--/kuzu--> |
の場合は
1 2 3 4 5 6 7 8 9 10 |
<div class="kuzu"> <?php /*--- パンくず --- */?> <div class="breadcrumb"> <a href="<?php echo home_url(); ?>">HOME</a> > </li> <?php foreach ( array_reverse(get_post_ancestors($post->ID)) as $parid ) { ?> <a href="<?php echo get_page_link( $parid );?>" title="<?php echo get_page($parid)->post_title; ?>"> <?php echo get_page($parid)->post_title; ?></a> > <?php } ?> </div> </div> <!--/kuzu--> |
へ。
抜粋でショートコードが見える対策
functions.phpに以下を追記
1 2 3 4 5 6 7 8 9 10 |
//ショートコードを外す function stinger_noshotcode( $content ) { if ( ! preg_match( '/\[.+?\]/', $content, $matches ) ) { return $content; } $content = str_replace( $matches[0], '', $content ); return $content; } |
home.php、sidebar.php、single.phpの
1 |
<?php echo mb_substr(get_the_excerpt(), 0, 100); ?> |
を
1 |
<?php echo mb_substr( strip_tags( stinger_noshotcode( $post->post_content ) ), 0, 100 ) . ''; ?> |
に変更。
※「100」の数字は箇所により異なる。
更新日を追加
functions.phpに以下を追記
1 2 3 4 5 6 7 8 9 10 11 12 |
//更新日の追加 function get_mtime($format) { $mtime = get_the_modified_time('Ymd'); $ptime = get_the_time('Ymd'); if ($ptime > $mtime) { return get_the_time($format); } elseif ($ptime === $mtime) { return null; } else { return get_the_modified_time($format); } } |
single.phpの
1 2 3 |
<h1 class="entry-title"> <?php the_title(); ?> </h1> |
の下に
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<div class="blogbox"> <p><span class="kdate">公開日: <time class="entry-date" datetime="<?php the_time('c') ;?>"> <?php the_time('Y/m/d') ;?> </time> : <?php if ($mtime = get_mtime('Y/m/d')) echo ' 最終更新日:' , $mtime; ?> </span> <?php the_category(', ') ?> <?php the_tags('', ', '); ?> <br> </p> </div> |
を追記
style.cssに
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
/*----------------------------- タイトル下 ------------------------------*/ .kizi .blogbox p { font-size: 12px; } .kizi .blogbox { background-color: #f3f3f3; } .kizi .blogbox p .kdate { background-color: #595959; margin-right: 10px; padding: 5px; color: #FFF; } |
を追記。
smart.cssに
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
/*----------------------------- タイトル下 ------------------------------*/ .kizi .blogbox { background-color: #f3f3f3; padding: 5px; border-top-width: 1px; border-bottom-width: 1px; border-top-style: dotted; border-bottom-style: dotted; border-top-color: #999; border-bottom-color: #999; margin-bottom: 10px; } .kizi .blogbox p { font-size: 12px; margin-bottom: 0px; } |
を追記
jQueryの読み込みの不要なコードの削除
functions.phpの
1 2 3 4 5 6 7 8 9 10 |
function register_user_script() { if (!is_admin()) { $script_directory = get_template_directory_uri(); wp_deregister_script('jquery'); wp_enqueue_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js'); wp_enqueue_script('MyTheme_InitScript',$script_directory.'/init.js',array('jquery')); } } add_action('init','register_user_script'); |
の
1 |
wp_enqueue_script('MyTheme_InitScript',$script_directory.'/init.js',array('jquery')); |
は削除して
1 2 3 4 5 6 7 8 |
function register_user_script() { if (!is_admin()) { $script_directory = get_template_directory_uri(); wp_deregister_script('jquery'); wp_enqueue_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js'); } } add_action('init','register_user_script'); |
に。
カスタムヘッダーの高さを自由に変更
functions.phpの
1 2 3 |
//カスタムヘッダー add_custom_image_header('','admin_header_style'); function admin_header_style() {} |
を
1 2 3 4 5 6 7 8 |
//カスタムヘッダー $args = array( 'width' => 986, 'height' => 150, 'flex-height' => true, 'default-image' => get_template_directory_uri() . '/images/stinger3.png', ); add_theme_support( 'custom-header', $args ); |
に。もし、変わっていても「flex-heighnt」となっていたら御修正ください。
Youtubeなどがスマホではみ出る事の修正
smart.cssに
1 2 3 4 5 |
.kizi img, .wp-caption, .kizi video, .kizi object, .kizi iframe, .kizi table { margin-bottom: 20px; height: auto; max-width: 100%!important; } |
を追記
スマホの関連記事のタイトルに隙間ができる問題の修正
smart.cssに
1 2 3 4 |
div dl dd .saisin { word-break: break-all; overflow: auto; } |
を追記。
以上です。