GoogleChromeでアンカーテキスト:hoverでアンダーラインがレンダリングされない
テキストサイズが12px(以下)時にアンカーテキストに:hoverにtext-decoration: underline;を指定するとうまくアンダーラインがレンダリングされない。
a:hover { text-decoration: underline; }
解決方法はテキストサイズを最低でも13pxにするか.
:hoverにpadding-bottom: 1px;を指定する。
a:hover {
padding-bottom: 1px;
text-decoration: underline;
}
いろいろ試しましたが、この二つしか見つかりませんでした。
- テキストサイズを最低でも13pxにする
- :hoverにpadding-bottom: 1px;を指定
モヤモヤしたままです。
WordPressパンくずリストをプラグインなしで実装する方法
WordPressでプラグインを使用せずにパンくずリストをfunction.phpから呼び出して使用する方法です。とってもシンプルに作っています。
/* * パンくずリスト */ function the__breadcrumb( $before = '', $after = '' ){ global $post;
$str = function( $link, $title ) { $sepa = ' / '; // ホーム echo '<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">'; echo '<a href="'.$link.'" itemprop="url">'; echo '<span itemprop="title">'.$title.'</span>'; echo '</a>'.( is_main_site() && is_front_page() ? '' : $sepa ); echo '</li>'; }; echo $before; echo '<ol class="breadcrumb">'; $str( get_home_url( '/' ), get_bloginfo( 'name' ) . ' - TOP' ); // 固定ページ if ( is_page() && $post->post_parent != 0 ) { $ancestors = array_reverse( get_ancestors( $post->ID, 'page' ) ); foreach( $ancestors as $ancestor ) { $str( get_permalink( $ancestor ), get_the_title( $ancestor ) ); } // 投稿ページ } elseif ( is_single() ) { $cat = get_the_category( $post->ID ); if ( isset( $cat, $cat[0] ) ) { $cat = $cat[0]; // 親カテゴリがある場合は親のカテゴリを追加 if ( $cat->parent!=0 ): $ancestors = array_reverse( get_ancestors( $cat->cat_ID, 'category' ) ); foreach( $ancestors as $ancestor ): $str( get_category_link( $ancestor ), get_the_category_by_ID( $ancestor ) ); endforeach; endif; // カテゴリ名 $str( get_category_link( $cat->cat_ID ), get_the_category_by_ID( $cat->cat_ID ) ); } // カテゴリページ } elseif ( is_category() ) { $cat = get_queried_object(); if ( $cat->parent!=0 ) { $ancestors = array_reverse( get_ancestors( $cat->cat_ID , 'category' ) ); foreach( $ancestors as $ancestor ) { $str( get_permalink( $ancestor ), get_the_title( $ancestor ) ); } } } // 検索ページでキーワードが入力されてない場合 if ( is_search() && !get_search_query() ) { echo '<li>'.'検索結果'.'</li>'; // 現在のページ } else { echo '<li>'.wp_get_document_title().'</li>'; } echo '</ol>'; echo $after; }
下記で実行
if ( function_exists( 'the__breadcrumb' ) ) { the__breadcrumb( '', '' ); }
wp_get_document_title();
の サイト名を消したい場合は
add_filter( 'document_title_parts', 'remove_title_sitename' ); function remove_title_sitename( $title ) { unset( $title['site'] ); if ( is_front_page() ) { unset( $title['title'] ); } else { unset( $title['tagline'] ); } return $title; }
WordPressのbody_classに独自のclass名を追加
投稿ページにカテゴリースラッグが英語の場合追加
固定ページにページスラッグが英語の場合追加
固定ページで親ページがあれば親ページのスラッグも追加
以下をfunctions.phpに追加。
/* * body_classに独自のclass名を追加 */ function add__body_class( $classes='' ) { global $page_id, $post; // 英語名のみ $check_eng = function( $prefix, $text ) { mb_regex_encoding( "Shift_jis" ); if ( preg_match( "/^[a-zA-Z0-9-]+$/", $text ) ) { $classes[] = $prefix . '-' . $text; } }; // 投稿ページでカテゴリースラッグを英語の場合追加 if ( is_single() ) { foreach( ( get_the_category( $post->ID ) ) as $cat ) { $cat_slug = $cat->category_nicename; $check_eng( 'category', $cat_slug ); } } // ページスラッグを英語の場合追加 if (is_page()) { $page_slug = get_page( $page_id )->post_name; $check_eng( 'page', $page_slug ); } // 親のページスラッグも英語の場合追加 if ( isset( $post ) && $post->post_parent != 0 ) { $ancestors = array_reverse( get_post_ancestors( $post->ID ) ); foreach( $ancestors as $ancestor ) { $ancestor = get_page( $ancestor ); $ancestor_slug = $ancestor->post_name; $check_eng( 'page', $ancestor_slug ); } } return $classes; } add_filter( 'body_class', 'add__body_class' );