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
※keyname の部分は作成したカスタムフィールドの名前に置き換える | |
そのまま出力 | |
<?php echo $post->keyname; ?> | |
または | |
<?php echo $post->{keyname}; ?> | |
HTMLをエスケープしたい場合 | |
<?php echo esc_html( $post->keyname ); ?> |
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 customed_queries ( $query ) { | |
if ( is_feed() ) { // フィードにカスタム投稿を含める | |
$query->set( 'post_type', array( 'post', 'gallery' ) ); | |
return $query; | |
} | |
if ( is_admin() || ! $query->is_main_query() ) { //管理画面とサブクエリは対象外 | |
return; | |
} | |
if ( $query->is_main_query() ) { |
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
/*------------------------------------------------------------------------------ | |
WordPress required | |
-------------------------------------------------------------------------------*/ | |
/*------ entry ------*/ | |
.hentry { | |
margin-bottom: 20px; | |
overflow: hidden; | |
} |
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
@charset "utf-8"; | |
/*------------------------------------------------------------------------------ | |
reset.css 2014.03.18 | |
-------------------------------------------------------------------------------*/ | |
html { overflow-y: scroll; } | |
article, aside, canvas, details, figcaption, figure, header, footer, hgroup, menu, nav, section, summary { display: block; } | |
body, div, dl, dt, dd, ul, ol, li, pre, code, form, fieldset, legend, input, textarea, p, blockquote, th, td { margin: 0; padding: 0; } | |
address, caption, cite, code, dfn, em, strong, th, var { font-style: normal; } | |
img, abbr, acronym, fieldset, a img { border: none; } |
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 | |
//add extra fields to category edit form hook | |
add_action ( 'edit_category_form_fields', 'extra_category_fields'); | |
//add extra fields to category edit form callback function | |
function extra_category_fields( $tag ) { //check for existing featured ID | |
$t_id = $tag->term_id; | |
$cat_meta = get_option( "category_$t_id"); | |
?> | |
<tr class="form-field"> | |
<th scope="row" valign="top"><label for="extra1">meta robots指定</label></th> |
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(is_category()): ?> | |
<h1><img src="<?php echo get_template_directory_uri(); ?>/images/title_<?php | |
$cat_id = get_query_var('cat'); | |
$cat = get_category($cat_id); | |
echo $cat->category_nicename; | |
?>.jpg" alt="<?php single_cat_title(); ?>" /></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 | |
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 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, $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
<table> | |
<tr> | |
<th>日付</th> | |
<th>タイトル</th> | |
</tr> | |
<?php | |
$postcount = 1; //奇数偶数をカウント | |
$news = get_posts( array( | |
'post_type' => 'type', | |
'posts_per_page' => -1, |
OlderNewer