This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $post; | |
if ( is_page() && $post->post_parent ): //子ページの場合 | |
?> | |
<h1><img src="<?php echo get_template_directory_uri(); ?>/images/title_<?php echo get_page_uri($post->post_parent); ?>.jpg" alt="<?php echo esc_attr( get_the_title($post->post_parent) ); ?>" /></h1> | |
<?php else: //親ページの場合 ?> | |
<h1><img src="<?php echo get_template_directory_uri(); ?>/images/title_<?php echo get_page_uri($post->ID); ?>.jpg" alt="<?php the_title_attribute(); ?>" /></h1> | |
<?php endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//パンくずのリッチスニペット対応 | |
function rich_bread_crumb($output, $args) { | |
if ($args['type'] == 'list') { | |
$output = preg_replace('|<li\s+(.*?)>|mi','<li ${1} itemscope="itemscope" itemtype="https://data-vocabulary.org/Breadcrumb">',$output); | |
$output = preg_replace('|<li\s+class="(.*?current.*?)".*?>|mi','<li class="${1}">',$output); | |
$output = preg_replace('|<a\s+(.*?)>|mi','<a ${1} itemprop="url"><span itemprop="title">',$output); | |
$output = str_replace('</a>','</span></a>',$output); | |
} | |
return $output; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( $post->my_description ): //meta descriptionの設定 ?> | |
<meta name="description" content="<?php echo esc_attr( $post->my_description ); ?>" /> | |
<?php else: ?> | |
<meta name="description" content="<?php bloginfo('description'); ?>" /> | |
<?php endif; ?> | |
<?php if ( $post->my_keywords ): //meta keywordsの設定 ?> | |
<meta name="keywords" content="<?php echo esc_attr( $post->my_keywords ); ?>" /> | |
<?php else: ?> | |
<meta name="keywords" content="デフォルトワード,デフォルトワード,デフォルトワード" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//コピペするなら3行目から↓ | |
function mypace_custom_title( $title ){ | |
if( is_singular() ){ //タイトルタグカスタマイズの範囲を条件分岐で指定 | |
$post_id = get_the_ID(); //投稿IDを取得 | |
$my_title = get_post_meta( $post_id, 'my_title', true ); //カスタムフィールドの値を取得 | |
if( $my_title ){ //カスタムフィールドに値がある時 | |
return esc_html( $my_title ); //エスケープして出力 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//コピペするなら3行目から↓ | |
function mypace_custom_title( $title, $sep ){ | |
if( is_singular() ){ //タイトルタグカスタマイズの範囲を条件分岐で指定 | |
$post_id = get_the_ID(); //投稿IDを取得 | |
$my_title = get_post_meta( $post_id, 'my_title', true ); //カスタムフィールドの値を取得 | |
if( $my_title ){ //カスタムフィールドに値がある時 | |
$blog_name = get_bloginfo('name'); | |
$title = esc_html( $my_title . " $sep " . $blog_name ); //フィールドの値 | サイト名 の形式に | |
return $title; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//コピペするなら3行目から↓ | |
function mypace_custom_title( $title ){ | |
if( is_singular() ){ //タイトルタグカスタマイズの範囲を条件分岐で指定 | |
$post_id = get_the_ID(); //投稿IDを取得 | |
$my_title = get_post_meta( $post_id, 'my_title', true ); //カスタムフィールドの値を取得 | |
if( $my_title ){ //カスタムフィールドに値がある時 | |
return esc_html( $my_title ); //エスケープして出力 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//コピペするなら3行目から↓ | |
function mypace_custom_title_separator( $sep ){ | |
$sep = '|'; | |
return $sep; | |
} | |
add_filter( 'document_title_separator', 'mypace_custom_title_separator' ); //フィルターフックで処理を上書き |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//コピペするなら3行目から↓ | |
function mypace_custom_title( $title ){ | |
if( is_singular() ){ //タイトルタグカスタマイズの範囲を条件分岐で指定 | |
$post_id = get_the_ID(); //投稿IDを取得 | |
$my_title = get_post_meta( $post_id, 'my_title', true ); //カスタムフィールドの値を取得 | |
if( $my_title ){ //カスタムフィールドに値がある時 | |
$title['title'] = esc_html( $my_title ); //ページタイトルの部分のみ上書き | |
return $title; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p> | |
<select name="year"> | |
<option value="">西暦</option> | |
<option value="2015"{year:checked#2015}>2015</option> | |
<option value="2014"{year:checked#2014}>2014</option> | |
<option value="2013"{year:checked#2013}>2013</option> | |
<option value="2012"{year:checked#2012}>2012</option> | |
<option value="2011"{year:checked#2011}>2011</option> | |
<option value="2010"{year:checked#2010}>2010</option> | |
<option value="2009"{year:checked#2009}>2009</option> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<meta name="robots" content="noindex"> | |
<title>印刷用ページのベース(例)</title> | |
<link rel='stylesheet' id='print-css' href='<?php echo esc_url( get_template_directory_uri() ); ?>/print.css' type='text/css' media='all' /> | |
</head> | |
<body> |