以下の例では、$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; ?>

この投稿へのコメント

コメントはまだありません。

コメントを残す

メールアドレスが公開されることはありません。

次のHTML タグと属性が使えます。
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CAPTCHA


ピックアップ記事

WordPress のURLの末尾のスラッシュ(トレイリングスラッシュ)を追加、または削除する

2024年03月03日 web関連WordPress
https://runebook.dev/ja/docs/wordpress/functions/untrailingslashit
「WordPress のURLの末尾のスラッシュ(トレイリングスラッシュ)を追加、または削除する」をはてなブックマークに追加

WordPressで特定の親カテゴリとその子カテゴリに所属する場合の条件分岐の方法

2022年11月12日 WordPress
functions.phpに以下を記述 [php]if ( ! function_exists( 'post_is_in_descendant_category' ) ) { function post_is_in_descendant_category( $cats, $_post = null ) { foreach ( (array) $cats as $c…
「WordPressで特定の親カテゴリとその子カテゴリに所属する場合の条件分岐の方法」をはてなブックマークに追加

記事のタイトルを表示

2011年11月24日 WordPress
[php] <?php the_title(); ?> [/php]
「記事のタイトルを表示」をはてなブックマークに追加

WordPressでindex.htmlとindex.phpを混在させる

2011年06月14日 WordPress
なんともない話題ではありますが、既存のサイトを公開したまま、index.phpの方で、WordPressを入れて、リニューアルをと思ってたんですが、index.phpもindex.htmlもWordPressのホームディレクトリにリダイレクトされてるようです。 どうしたもんかと思ってたら、簡単に解決する方法がありました。 wp-include内のcanonical.phpファイルを開き、270行…
「WordPressでindex.htmlとindex.phpを混在させる」をはてなブックマークに追加

親カテゴリIDを取得・表示

2011年11月28日 WordPress
現在表示中のページ(記事)の親カテゴリIDを表示させます。 [php] <?php // 現在のカテゴリ-を配列取得 $cat_now = get_the_category(); // 親の情報を$cat_nowに格納 $cat_now = $cat_now[0]; //category_parentを$parent_idに格納 $parent_id = $cat_now->cate…
「親カテゴリIDを取得・表示」をはてなブックマークに追加
© graffiti on the web . All rights reserved. WordPress Theme by comfy