echo "<img src='img/s1.png' alt='管理人の評判星1個'/>\n";
日: 2013年10月27日
タイトルもしくはog:titleの分岐
<meta property="og:title" content="<?php
wp_title( '|', true, 'right' );
if(is_tax('genre')): //大カテゴリ21---------------------------------
$super = single_term_title('', false);
$args = array(
'posts_per_page' => 1,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'midashi',//タクソノミー見出しの
'field' => 'slug',
'terms' => array( $super, '予備' ),//タームに現在のタームを入れるsuper※条件midashiとgenreのターム名は同じ
//'operator'=>'NOT IN'
),
),
'post_type' => 'd_midashi_top', //カスタムポスト見出しトップの
);
query_posts( $args );
if ( have_posts () ) :
while ( have_posts() ) :
the_post();
echo get_post_meta($post->ID,"見出し文",true);
endwhile;
endif;
//genreのタクソノミーだったら終わり
?><?php
endif; //else:
wp_reset_query();
/*
* Print the <title> tag based on what is being viewed.
*/
global $page, $paged;
if(is_singular( 'performer' ) )://パフォーマー個---------------------------------
echo get_post_meta($post->ID,"キャッチコピー",true);
echo ' ';
endif;
if(is_tax('chiiki')): //パフォーマー地域---------------------------------
echo 'イベントレポート ';
endif;
// Add the blog name.
bloginfo( 'name' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
echo " | $site_description";
if(is_page()): //固定ページ--------------------------------
echo " | $site_description";
endif;
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
echo ' | ' . sprintf( __( 'Page %s', 'twentyeleven' ), max( $paged, $page ) );
?>" />
og:typeを分岐
<?php if(is_home()): //ホームなら?> <meta property="og:type" content="website"> <?php else: ?> <meta property="og:type" content="article"> <?php endif; ?>
og:descriptionにカスタムフィールドを改行させないで
<?php if(is_singular( 'performer' ) )://パフォーマー個人---------------------------------?>
<meta property="og:description" content="<?php echo mb_substr( str_replace(array("\r\n","\r","\n"),'',strip_tags(get_post_meta($post->ID,"プロフィール",true))), 0, 120); //ソースを改行させない カスタムフィールドの文字を指定数だけ入れる?>">
<?php elseif(is_singular( 'event_report' ) )://レポート個---------------------------------?>
<meta property="og:description" content="<?php echo mb_substr( str_replace(array("\r\n","\r","\n"),'',strip_tags($post->post_content)), 0, 120 ); //ソースを改行させない コンテンツの文字を指定数だけ入れる?>">
<?php else: ?>
<meta property="og:description" content="大道芸人、マジシャン、似顔絵師、演奏家などの出張派遣、様々なパフォーマーを派遣いたします。全国の芸人が総勢250名以上在籍!イベント企画会社様から個人のイベントまで、驚きの低価格にて派遣いたします。" />
<?php endif; ?>
Custom Field GUI Utility Extenderで表示した画像をog:imgに
<?php if(is_singular( 'event_report' )): //シングルより先に読み込む?>
<meta property="og:image" content="<?php $imagefield = get_imagefield('レポート画像1');
$attachment = get_attachment_object($imagefield['id']);
$imgattr = wp_get_attachment_image_src($imagefield['id'], 'thumbnail'); // thumbnail, large, medium, full を指定
print $imgattr[0];
?>" />
<?php elseif(is_singular( 'performer' )): ?>
<meta property="og:image" content="<?php $imagefield = get_imagefield('パフォーマー画像1');
$attachment = get_attachment_object($imagefield['id']);
$imgattr = wp_get_attachment_image_src($imagefield['id'], 'thumbnail'); // thumbnail, large, medium, full を指定
print $imgattr[0];
?>" />
<!--それ以外なら-->
<?php else: ?>
<meta property="og:image" content="http://www.xn--q9js4nqcxfya8d9mb5974lbbyb.com/img/face.jpg" />
<?php endif; ?>
thumbnailでええの?fullでしょ?
Custom Field GUI Utility Extender 画像出力
<?php if(get_post_meta($post->ID, 'パフォーマー画像1', true)): ?>
<!--サムネイルコード-->
<?php
$imagefield = get_imagefield('パフォーマー画像1');
$attachment = get_attachment_object($imagefield['id']);
$imgattr = wp_get_attachment_image_src($imagefield['id'], 'thumbnail'); // thumbnail, large, medium, full を指定
echo '<image src="' . $imgattr[0] . '" width="' . $imgattr[1] . '" height="' . $imgattr[2] . '" alt="' . get_the_title() . '" title="' . get_the_title() . '" />';
?>
<!--サムネイルコード-->
<?php endif; ?>
投稿TOP1記事の後ろだけ広告を入れる
<?php
if ( have_posts () ) :
while (have_posts()) : the_post(); $counter++;
?>
<?php include("d_roop_box.php") ?>
<?php if ($counter <= 1) {
include("d_ad_1_2.php");
} ?>
<!----閉じループタグ----->
<?php
endwhile;
endif;
?>
<!---------------リセットクエリ--------------------------------------------->
<?php wp_reset_query(); ?>