TOMOIKU*ブログ
7.132016
賢威トップ最新情報や記事ページなどの日付を消す方法は簡単だった
Contents
トップ最新情報や記事ページなどの日付を消す
サイトの内容によっては日付を削除したい場合があります。
デフォルトではすべて日付がついていますので、サイトの目的によって非表示にしたいと思っている方は、簡単にできちゃいますので早速とりかかりましょう。
部分的に削除したい方はCSSを書き換えることをしますので、バックアップはしておいてください。
すべてのページの日付を消す場合
ダッシュボード>設定>一般 に進む。
一般設定の下部の「日付のフォーマット」と「時刻フォーマット」を空白にして、保存してください。
全てのページの日付が非表示になります。
トップページの最新情報の日付の位置が変に空白になっていますが「トップページの最新情報の日付だけを消したい場合」の解決法と同じ要領で整います。
一部のページの日付を消したい場合
トップページの最新情報の日付だけを消したい場合
ダッシュボード>外観>テーマの編集>メインインデックスのテンプレート(index.php)
<!--最新情報--> <h2><?php _e('Latest Info','keni') ;?></h2> <div class="contents"> <?php $new_info = the_keni('new_info'); ?> <?php if ($new_info == 1 or empty($new_info)): ?> <dl class="news"> <?php elseif ($new_info == 2): ?> <dl class="news02"> <?php endif; ?> <?php $new_info_rows = (trim(mb_convert_kana(the_keni('new_info_rows'),"as"))); if (!preg_match('/^[0-9]+$/', $new_info_rows) ) { $new_info_rows = 5; } newposts_keni($new_info_rows,1,1,"year",0,the_keni('new_info')); ?> </dl>
〈前〉
newposts_keni($new_info_rows,1,1,”year“,0,the_keni(‘new_info’)); ?>
↓
year を del に編集
↓
〈編集後〉
newposts_keni($new_info_rows,1,1,”del“,0,the_keni(‘new_info’)); ?>
空白をつめるように編集
ダッシュボード>外観>テーマの編集>design.css
#main-contents dl.news dd{ margin: 0 0 10px 0; padding: 0 1em 0.8em 16.5em; border-bottom: 1px dotted #414141; } /*カテゴリの文字数が多い場合はコメントアウトを解除*/
〈前〉
padding: 0 1em 0.8em 16.5em;
↓
16.5em を 7em に編集
↓
〈編集後〉
padding: 0 1em 0.8em 7em;
トップページの記事一覧の日付だけを消したい場合
ダッシュボード>外観>テーマの編集>メインインデックスのテンプレート(index.php)
<h2 class="post-title"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <p class="post-meta"><span class="post-data"><?php the_time(get_option( 'date_format')); //the_time(‘Y年m月d日’) ?></span> <?php if (!is_tag()) { get_category_keni(', '); } ?></p> <div class="contents clearfix">
〈前〉
<span class=”post-data”><?php the_time(get_option( ‘date_format’)); //the_time(‘Y年m月d日’) ?></span>
↓
削除してください。
〈編集後〉
記事内上部の日付だけを消したい場合
ダッシュボード>外観>テーマの編集>単一記事の投稿(single.php)
<div class="post"> <h2 class="post-title"><?php the_title(); ?></h2> <p class="post-meta"><span class="post-data"><?php the_time(get_option( 'date_format')); //the_time('Y年m月d日') ?></span> <?php if (!is_attachment()) { ?>[<span class="post-cat"><?php the_category(', ') ?></span>]<?php } ?></p> <?php get_template_part('social-button'); ?>
〈前〉
<span class=”post-data”><?php the_time(get_option( ‘date_format’)); //the_time(‘Y年m月d日’) ?></span>
↓
削除してください。
いかがでしょう…日付を消せましたか?
目的に応じて、カスタマイズして理想に近づけていくのも楽しいです。
<健康を意識した目的別レシピ>
生活を彩る 関連記事
* TOMOIKUの姉妹サイト紹介 *