예제 #1
0
    }
    if (get_top_page_meta_keyword()) {
        //メタキーワード
        ?>
<meta name="keywords" content="<?php 
        echo get_top_page_meta_keyword();
        ?>
">
<?php 
    }
}
//投稿ページにMETAタグを挿入するとき
if (is_singular() && is_meta_description_insert()) {
    ?>
<meta name="description" content="<?php 
    echo get_the_description();
    ?>
" />
<?php 
}
//投稿ページにMETAキーワードを挿入するとき
if (is_single() && is_meta_keywords_insert()) {
    $categories = get_the_category($post->ID);
    $category_names = array();
    foreach ($categories as $category) {
        array_push($category_names, $category->cat_name);
    }
    ?>
<meta name="keywords" content="<?php 
    echo implode($category_names, ',');
    ?>
예제 #2
0
?>

<!-- Twitter Card -->
<meta name="twitter:card" content="<?php 
echo get_twitter_card_type();
//Twitterのカードタイプを取得
?>
">

<?php 
if (is_singular()) {
    //単一記事ページの場合
    if (have_posts()) {
        while (have_posts()) {
            the_post();
            echo '<meta name="twitter:description" content="' . get_the_description() . '">';
            echo "\n";
            //抜粋を表示
        }
    }
    $title = get_the_title();
    if (is_front_page()) {
        $title = get_bloginfo('name');
    }
    echo '<meta name="twitter:title" content="';
    echo $title;
    echo '">';
    echo "\n";
    //単一記事タイトルを表示
    echo '<meta name="twitter:url" content="';
    the_permalink();
예제 #3
0
<!-- OGP -->
<meta property="og:type" content="<?php 
echo is_singular() ? 'article' : 'website';
?>
">
<?php 
if (is_singular()) {
    //単一記事ページの場合
    if (have_posts()) {
        while (have_posts()) {
            the_post();
            echo '<meta property="og:description" content="' . get_the_description() . '">';
            echo "\n";
            //抜粋を表示
        }
    }
    echo '<meta property="og:title" content="';
    the_title();
    echo '">';
    echo "\n";
    //単一記事タイトルを表示
    echo '<meta property="og:url" content="';
    the_permalink();
    echo '">';
    echo "\n";
    //単一記事URLを表示
} else {
    //単一記事ページページ以外の場合(アーカイブページやホームなど)
    $description = get_bloginfo('description');
    $title = get_bloginfo('name');
    $url = home_url();