<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									サイトマップをツリー上に作る方法 - Cocoonテーマに関する質問				            </title>
            <link>https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/</link>
            <description>Cocoon ディスカッション掲示板</description>
            <language>ja</language>
            <lastBuildDate>Wed, 22 Jul 2026 23:25:05 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: サイトマップをツリー上に作る方法</title>
                        <link>https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85022</link>
                        <pubDate>Thu, 01 May 2025 13:24:14 +0000</pubDate>
                        <description><![CDATA[@chu-ya とてもわかりやすい解説ありがとうございました。無事導入することができました。]]></description>
                        <content:encoded><![CDATA[<p>@chu-ya <br />とてもわかりやすい解説ありがとうございました。<br />無事導入することができました。</p>]]></content:encoded>
						                            <category domain="https://wp-cocoon.com/community/cocoon-theme/">Cocoonテーマに関する質問</category>                        <dc:creator>xxxciho</dc:creator>
                        <guid isPermaLink="true">https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85022</guid>
                    </item>
				                    <item>
                        <title>RE: サイトマップをツリー上に作る方法</title>
                        <link>https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85017</link>
                        <pubDate>Thu, 01 May 2025 11:25:38 +0000</pubDate>
                        <description><![CDATA[●答え
ショートコードsitemap_treeでツリー表示します。自己責任で願います。
functions.phpに追加。
// サイトマップをツリー形式で表示するショートコード
add_shortcode(&#039;sitemap_tree&#039;, function() {
  $output = &#039;&lt;ul class=&quot;my-hierarchy&quot;&gt;&#039;;

  ...]]></description>
                        <content:encoded><![CDATA[<p><span style="font-size: 14pt"><strong>●答え</strong></span></p>
<p>ショートコードsitemap_treeでツリー表示します。自己責任で願います。</p>
<p>functions.phpに追加。</p>
<pre contenteditable="false">// サイトマップをツリー形式で表示するショートコード
add_shortcode('sitemap_tree', function() {
  $output = '&lt;ul class="my-hierarchy"&gt;';

  // 固定ページのツリー表示
  $output .= '&lt;li&gt;&lt;strong&gt;固定ページ&lt;/strong&gt;&lt;ul&gt;';
  $pages = get_pages();
  $output .= sitemap_tree_render_pages($pages);
  $output .= '&lt;/ul&gt;&lt;/li&gt;';

  // 投稿のカテゴリーと投稿のツリー表示
  $output .= '&lt;li&gt;&lt;strong&gt;投稿&lt;/strong&gt;&lt;ul&gt;';
  $output .= sitemap_tree_render_categories(0);
  $output .= '&lt;/ul&gt;&lt;/li&gt;';

  $output .= '&lt;/ul&gt;';

  return $output;
});


// 固定ページを階層構造で再帰的に表示
function sitemap_tree_render_pages($pages, $parent_id = 0) {
  $output = '';
  foreach ($pages as $page) {
    if ($page-&gt;post_parent == $parent_id) {
      $output .= '&lt;li&gt;&lt;a href="' . get_permalink($page) . '"&gt;' . esc_html($page-&gt;post_title) . '&lt;/a&gt;';
      $children = sitemap_tree_render_pages($pages, $page-&gt;ID);
      if ($children) {
        $output .= '&lt;ul&gt;' . $children . '&lt;/ul&gt;';
      }
      $output .= '&lt;/li&gt;';
    }
  }
  return $output;
}

// カテゴリーと投稿を階層構造で再帰的に表示
function sitemap_tree_render_categories($parent_id) {
  $output = '';
  $categories = get_categories();

  foreach ($categories as $category) {
    $output .= '&lt;li&gt;' . esc_html($category-&gt;name);
    
    // 投稿を取得
    $posts = get_posts();

    // 投稿または子カテゴリーがあればリスト表示
    if (!empty($posts) || has_child_category($category-&gt;term_id)) {
      $output .= '&lt;ul&gt;';

      // 投稿をリスト化
      foreach ($posts as $post) {
        $output .= '&lt;li&gt;&lt;a href="' . get_permalink($post) . '"&gt;' . esc_html($post-&gt;post_title) . '&lt;/a&gt;&lt;/li&gt;';
      }

      // 子カテゴリーを再帰的に処理
      $output .= sitemap_tree_render_categories($category-&gt;term_id);

      $output .= '&lt;/ul&gt;';
    }

    $output .= '&lt;/li&gt;';
  }

  return $output;
}

// 指定カテゴリーに子カテゴリーが存在するかチェック
function has_child_category($term_id) {
  $children = get_categories();
  return !empty($children);
}</pre>
<p>style.cssに追加。</p>
<pre contenteditable="false">.article .my-hierarchy {
  background-color: #000;
  color: #eaeaea;
  font-family: 'Menlo', 'Consolas', 'monaco', 'monospace', 'ＭＳ ゴシック', sans-serif;
  padding: 15px;
  overflow-x: auto;
  white-space: nowrap;
}

.article .my-hierarchy::-webkit-scrollbar {
  height: 10px;
}

.article .my-hierarchy::-webkit-scrollbar-thumb {
  background-color: #ccc;
}

.article .my-hierarchy li {
  list-style: none;
  margin: 0;
  padding-left: 1em;
  position: relative;
}

.article .my-hierarchy ul {
  margin: 0;
  padding-left: 1em;
}

.article .my-hierarchy ul li:before {
  background-color: #fff;
  content: '';
  height: 1px;
  left: -0.5em;
  margin: auto;
  position: absolute;
  top: 0.75em;
  width: 1em;
}

.article .my-hierarchy ul li:after {
  background-color: #fff;
  bottom: 0;
  content: '';
  height: 100%;
  left: -0.5em;
  position: absolute;
  top: 0;
  width: 1px;
}

.article .my-hierarchy ul li:last-child:after {
  height: 0.75em;
}</pre>]]></content:encoded>
						                            <category domain="https://wp-cocoon.com/community/cocoon-theme/">Cocoonテーマに関する質問</category>                        <dc:creator>大門未知子</dc:creator>
                        <guid isPermaLink="true">https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85017</guid>
                    </item>
				                    <item>
                        <title>RE: サイトマップをツリー上に作る方法</title>
                        <link>https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85010</link>
                        <pubDate>Thu, 01 May 2025 07:07:52 +0000</pubDate>
                        <description><![CDATA[本件はコピペで実現でできる内容ではありません。
ご自身で、ツリー表示するCSSとHTMLを参考に、ショートコードを作成すれば、自動化できると言うことです。
Cocoonのsitemapショートコードで十分だと思いますが？]]></description>
                        <content:encoded><![CDATA[<p></p>
<p>こちらは投稿が増えたときに自動更新される機能はないですよね？</p>
<p></p>
<p>本件はコピペで実現でできる内容ではありません。</p>
<p>ご自身で、ツリー表示するCSSとHTMLを参考に、ショートコードを作成すれば、自動化できると言うことです。</p>
<p>Cocoonのsitemapショートコードで十分だと思いますが？</p>
<p> </p>]]></content:encoded>
						                            <category domain="https://wp-cocoon.com/community/cocoon-theme/">Cocoonテーマに関する質問</category>                        <dc:creator>大門未知子</dc:creator>
                        <guid isPermaLink="true">https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85010</guid>
                    </item>
				                    <item>
                        <title>RE: サイトマップをツリー上に作る方法</title>
                        <link>https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85008</link>
                        <pubDate>Thu, 01 May 2025 06:59:19 +0000</pubDate>
                        <description><![CDATA[@chu-ya 
ご教示ありがとうございます。確かに上記HTMLとCSSを設定すると、罫線を使ったサイトツリーのようにはなりましたが、こちらは投稿が増えたときに自動更新される機能はないですよね？もしそうであれば、毎回手動で増やすとなると手間になってしまうので、自動更新される方を優先し罫線デザインは諦めようと思いますが、上記はお間違い無いでしょうか。]]></description>
                        <content:encoded><![CDATA[<p>@chu-ya </p>
<p>ご教示ありがとうございます。<br />確かに上記HTMLとCSSを設定すると、罫線を使ったサイトツリーのようにはなりましたが、<br />こちらは投稿が増えたときに自動更新される機能はないですよね？<br /><br />もしそうであれば、毎回手動で増やすとなると手間になってしまうので、<br />自動更新される方を優先し罫線デザインは諦めようと思いますが、<br />上記はお間違い無いでしょうか。</p>]]></content:encoded>
						                            <category domain="https://wp-cocoon.com/community/cocoon-theme/">Cocoonテーマに関する質問</category>                        <dc:creator>xxxciho</dc:creator>
                        <guid isPermaLink="true">https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85008</guid>
                    </item>
				                    <item>
                        <title>RE: サイトマップをツリー上に作る方法</title>
                        <link>https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85007</link>
                        <pubDate>Thu, 01 May 2025 05:54:53 +0000</pubDate>
                        <description><![CDATA[浅学で申し訳ないのですが、投稿していただいた画像のようなツリーはどのようなコードで描かれているのでしょうか。

以下が参考になりませんか？]]></description>
                        <content:encoded><![CDATA[<blockquote>
<p><span>浅学で申し訳ないのですが、投稿していただいた画像のようなツリーは</span><br /><span>どのようなコードで描かれているのでしょうか。</span></p>
</blockquote>
<p>以下が参考になりませんか？</p>
https://www.will3in.co.jp/frontend-blog/article/expression-sitemap-tree-with-css-only/<br />
<p> </p>
<p> </p>]]></content:encoded>
						                            <category domain="https://wp-cocoon.com/community/cocoon-theme/">Cocoonテーマに関する質問</category>                        <dc:creator>大門未知子</dc:creator>
                        <guid isPermaLink="true">https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85007</guid>
                    </item>
				                    <item>
                        <title>RE: サイトマップをツリー上に作る方法</title>
                        <link>https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85006</link>
                        <pubDate>Thu, 01 May 2025 05:45:55 +0000</pubDate>
                        <description><![CDATA[@chu-ya 
回答ありがとうございます。やはりルクセリタスの機能だったんですね…。
現在、縦軸で上から下に年代が下る年表のようなものをサイトのメインに据えたいと思っており、ツリー構造のサイトマップが一番それに近かったので、もしCSSなどで実現できればそうしたいと思っています。
浅学で申し訳ないのですが、投稿していただいた画像のようなツリーはどのようなコードで描かれてい...]]></description>
                        <content:encoded><![CDATA[<p>@chu-ya </p>
<p>回答ありがとうございます。やはりルクセリタスの機能だったんですね…。</p>
<p>現在、縦軸で上から下に年代が下る年表のようなものをサイトのメインに据えたいと思っており、<br />ツリー構造のサイトマップが一番それに近かったので、もしCSSなどで実現できればそうしたいと思っています。</p>
<p>浅学で申し訳ないのですが、投稿していただいた画像のようなツリーは<br />どのようなコードで描かれているのでしょうか。</p>]]></content:encoded>
						                            <category domain="https://wp-cocoon.com/community/cocoon-theme/">Cocoonテーマに関する質問</category>                        <dc:creator>xxxciho</dc:creator>
                        <guid isPermaLink="true">https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85006</guid>
                    </item>
				                    <item>
                        <title>RE: サイトマップをツリー上に作る方法</title>
                        <link>https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85004</link>
                        <pubDate>Thu, 01 May 2025 05:11:15 +0000</pubDate>
                        <description><![CDATA[●回答
サイトマップのツリー表示はテーマLuxeritasの独自機能のようです
Cocoonはツリー表示しません。

●プラグイン
PS Auto Sitemapのスタイル「ドキュメントツリー」が似た感じかと思います。現在、プラグインはダウンロード停止となっています

●補足
カテゴリーをツリー表示し、各投稿を表示させる独自のショートコードとCSSで実現可能です。ツ...]]></description>
                        <content:encoded><![CDATA[<p><span style="font-size: 14pt"><strong>●回答</strong></span></p>
<p>サイトマップのツリー表示はテーマ<span style="color: #ff0000">Luxeritasの独自機能</span>のようです。<br /><br />https://thk.kanzae.net/wp/point/t295/</p>
<p>Cocoonはツリー表示しません。</p>
<p>https://wp-cocoon.com/sitemap-shortcode/</p>
<hr />
<p><span style="font-size: 14pt"><strong>●プラグイン</strong></span></p>
<p>PS Auto Sitemapのスタイル「ドキュメントツリー」が似た感じかと思います。<br />現在、プラグインはダウンロード停止となっています。<br /><br />https://fujimotoyousuke.com/ps-auto-sitemap_wordpress/</p>
<hr />
<p><span style="font-size: 14pt"><strong>●補足</strong></span></p>
<p>カテゴリーをツリー表示し、各投稿を表示させる独自のショートコードとCSSで実現可能です。<br />ツリー表示するにあたり、投稿に複数カテゴリーを設定した場合の考慮が必要です。</p>
<p>サイトマップ自体、余り閲覧されなず、わざわざツリー表示する必要はないと思います。</p>
<div id="wpfa-43087" class="wpforo-attached-file"><a class="wpforo-default-attachment" title="a.png" href="//wp-cocoon.com/wp-content/uploads/wpforo/default_attachments/1746076275-a.png" target="_blank" rel="noopener"><i class="fas fa-paperclip"></i> a.png</a></div>]]></content:encoded>
						                            <category domain="https://wp-cocoon.com/community/cocoon-theme/">Cocoonテーマに関する質問</category>                        <dc:creator>大門未知子</dc:creator>
                        <guid isPermaLink="true">https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-85004</guid>
                    </item>
				                    <item>
                        <title>サイトマップをツリー上に作る方法</title>
                        <link>https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-84991</link>
                        <pubDate>Wed, 30 Apr 2025 16:48:21 +0000</pubDate>
                        <description><![CDATA[表題の通り、サイトマップをツリー構造で作る方法はあるでしょうか。
 
6年以上前、ルクセリタスを使っていた頃に画像のようなツリー型のサイトマップを作成したことがあり、
その時はプラグインか何かを使って簡単に作成でき、またページが増えるたびに自動更新できていた覚えがあるのですが、
どのプラグインか失念してしまったため質問しました。
Cocoonならではの機能でなくてもプ...]]></description>
                        <content:encoded><![CDATA[<p>表題の通り、サイトマップをツリー構造で作る方法はあるでしょうか。</p>
<p> </p>
<p>6年以上前、ルクセリタスを使っていた頃に画像のようなツリー型のサイトマップを作成したことがあり、</p>
<p>その時はプラグインか何かを使って簡単に作成でき、またページが増えるたびに自動更新できていた覚えがあるのですが、</p>
<p>どのプラグインか失念してしまったため質問しました。</p>
<p>Cocoonならではの機能でなくてもプラグインなどで可能であれば教えていただきたいです。</p>
<p>よろしくお願いいたします。</p>
<p> </p>
<div id="wpfa-43075" class="wpforo-attached-file"><a class="wpforo-default-attachment" href="//wp-cocoon.com/wp-content/uploads/wpforo/default_attachments/1746031701-404ddfebe781e449310659830816bff2.png" target="_blank" title="404ddfebe781e449310659830816bff2.png"><i class="fas fa-paperclip"></i>&nbsp;404ddfebe781e449310659830816bff2.png</a></div>]]></content:encoded>
						                            <category domain="https://wp-cocoon.com/community/cocoon-theme/">Cocoonテーマに関する質問</category>                        <dc:creator>xxxciho</dc:creator>
                        <guid isPermaLink="true">https://wp-cocoon.com/community/cocoon-theme/%e3%82%b5%e3%82%a4%e3%83%88%e3%83%9e%e3%83%83%e3%83%97%e3%82%92%e3%83%84%e3%83%aa%e3%83%bc%e4%b8%8a%e3%81%ab%e4%bd%9c%e3%82%8b%e6%96%b9%e6%b3%95/#post-84991</guid>
                    </item>
							        </channel>
        </rss>
		