現在表示中のページ(記事)の親カテゴリIDを表示させます。
[php]
<?php
// 現在のカテゴリ-を配列取得
$cat_now = get_the_category();
// 親の情報を$cat_nowに格納
$cat_now = $cat_now[0];
//category_parentを$parent_idに格納
$parent_id = $cat_now->cate…
以下の例では、$tag_descriptionで投稿タグの説明を取得し、表示しています。
<?php $tag_name = single_tag_title( '', false ); echo "<h2>".$tag_name."</h2>"; echo "<h3>タグの説明 : ".$tag_name."</h3>"; $tag_description = tag_description(); if ( ! empty( $tag_description ) ) echo apply_filters( 'tag_archive_meta', '<div class="tag-archive-meta">' . $tag_description . '</div>' ); echo "<h2>".$tag_name."に関連する投稿一覧</h2>"; $q = "tag=".$tag_name; if ( have_posts() ) : query_posts($q); ?> <ul> <?php while (have_posts()) : the_post(); ?> <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li> <?php endwhile;?> </ul> <?php endif; ?>
この投稿へのコメント
コメントはまだありません。