<?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/%e4%ba%ba%e6%b0%97%e8%a8%98%e4%ba%8b%e5%8f%96%e5%be%97%e3%81%ae%e6%94%b9%e5%96%84/</link>
            <description>Cocoon ディスカッション掲示板</description>
            <language>ja</language>
            <lastBuildDate>Tue, 13 Oct 2026 19:25:36 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: 人気記事取得の改善</title>
                        <link>https://wp-cocoon.com/community/cocoon-theme/%e4%ba%ba%e6%b0%97%e8%a8%98%e4%ba%8b%e5%8f%96%e5%be%97%e3%81%ae%e6%94%b9%e5%96%84/#post-87420</link>
                        <pubDate>Sun, 14 Dec 2025 13:53:42 +0000</pubDate>
                        <description><![CDATA[ご確認いただきありがとうございます。]]></description>
                        <content:encoded><![CDATA[<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/%e4%ba%ba%e6%b0%97%e8%a8%98%e4%ba%8b%e5%8f%96%e5%be%97%e3%81%ae%e6%94%b9%e5%96%84/#post-87420</guid>
                    </item>
				                    <item>
                        <title>RE: 人気記事取得の改善</title>
                        <link>https://wp-cocoon.com/community/cocoon-theme/%e4%ba%ba%e6%b0%97%e8%a8%98%e4%ba%8b%e5%8f%96%e5%be%97%e3%81%ae%e6%94%b9%e5%96%84/#post-87405</link>
                        <pubDate>Fri, 12 Dec 2025 11:37:42 +0000</pubDate>
                        <description><![CDATA[----------------------------------------------テーマ名：Cocoonバージョン：2.8.9カテゴリー数：18タグ数：123ユーザー数：1----------------------------------------------サポートされていることを確認しました。本件をクローズとします。]]></description>
                        <content:encoded><![CDATA[<p>----------------------------------------------<br />テーマ名：Cocoon<br />バージョン：2.8.9<br />カテゴリー数：18<br />タグ数：123<br />ユーザー数：1<br />----------------------------------------------<br />サポートされていることを確認しました。<br />本件をクローズとします。</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/%e4%ba%ba%e6%b0%97%e8%a8%98%e4%ba%8b%e5%8f%96%e5%be%97%e3%81%ae%e6%94%b9%e5%96%84/#post-87405</guid>
                    </item>
				                    <item>
                        <title>RE: 人気記事取得の改善</title>
                        <link>https://wp-cocoon.com/community/cocoon-theme/%e4%ba%ba%e6%b0%97%e8%a8%98%e4%ba%8b%e5%8f%96%e5%be%97%e3%81%ae%e6%94%b9%e5%96%84/#post-87402</link>
                        <pubDate>Fri, 12 Dec 2025 11:07:33 +0000</pubDate>
                        <description><![CDATA[ご指摘ありがとうございます。$limit = -1で全件取得するように修正しておきました]]></description>
                        <content:encoded><![CDATA[<p>ご指摘ありがとうございます。<br />$limit = -1で全件取得するように修正しておきました。<br />https://github.com/xserver-inc/cocoon/commit/0a3df69534fd2dd94fadcc8d9d265a372ebea789</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/%e4%ba%ba%e6%b0%97%e8%a8%98%e4%ba%8b%e5%8f%96%e5%be%97%e3%81%ae%e6%94%b9%e5%96%84/#post-87402</guid>
                    </item>
				                    <item>
                        <title>人気記事取得の改善</title>
                        <link>https://wp-cocoon.com/community/cocoon-theme/%e4%ba%ba%e6%b0%97%e8%a8%98%e4%ba%8b%e5%8f%96%e5%be%97%e3%81%ae%e6%94%b9%e5%96%84/#post-87399</link>
                        <pubDate>Thu, 11 Dec 2025 08:59:08 +0000</pubDate>
                        <description><![CDATA[既存のコードについて改善の提案をします。
----------------------------------------------テーマ名：Cocoonバージョン：2.8.9カテゴリー数：18タグ数：123ユーザー数：1----------------------------------------------
●改善点
人気記事レコードを取得する処理で、SQLにLI...]]></description>
                        <content:encoded><![CDATA[<p>既存のコードについて改善の提案をします。</p>
<p>----------------------------------------------<br />テーマ名：Cocoon<br />バージョン：2.8.9<br />カテゴリー数：18<br />タグ数：123<br />ユーザー数：1<br />----------------------------------------------</p>
<p><span style="font-size: 14pt"><strong>●改善点</strong></span></p>
<p>人気記事レコードを取得する処理で、<span style="color: #ff0000">SQLにLIMIT が付いている</span>。<br />そのため、全件取得する場合はpopular_listのcountオプションに想定以上の値（例：9999）を指定する必要がある。</p>
<p>WP_Queryと同様に<span style="color: #ff0000">$limit = -1で全件取得</span>できるように改善する。</p>
<p>https://github.com/xserver-inc/cocoon/blob/1a2324627f0c4e55cecaad11d860635be4fbd6f1/lib/page-access/access-func.php#L332-L361</p>
<hr />
<p><span style="font-size: 14pt"><strong>●目的</strong></span></p>
<p>get_access_ranking_recordsを使用して、人気順の一覧を作成する際に活用する。</p>
<pre contenteditable="false">if ( !function_exists( 'wrap_joined_wp_posts_query' ) ):
function wrap_joined_wp_posts_query($query, $limit, $author, $post_type, $snippet = 0){
  global $wpdb;
  $wp_posts = $wpdb-&gt;posts;
  $ranks_posts = 'ranks_posts';
  //$post_type = is_page() ? 'page' : 'post';
  $author_query = null;
  if ($author) {
    $author_query = ' AND post_author = '.esc_sql($author);
  }
  // $snippet_column = '';
  // if ($snippet) {
  //   $snippet_column = 'post_content, ';
  // }

  $query = "
    SELECT ID, sum_count, post_title, post_author, post_date, post_modified, post_status, post_type, comment_count FROM (
      {$query}
    ) AS {$ranks_posts}
    INNER JOIN {$wp_posts} ON {$ranks_posts}.post_id = {$wp_posts}.id
    WHERE post_status = 'publish' AND
          post_type = '{$post_type}'".
          $author_query."
    ORDER BY sum_count DESC, post_date DESC
  ";

  // LIMIT は 1以上の場合のみ付与
  if ($limit &gt; 0) {
    $query .= " LIMIT $limit";
  }

  //_v($query);
  //var_dump($query);
  return $query;
}
endif;
</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/%e4%ba%ba%e6%b0%97%e8%a8%98%e4%ba%8b%e5%8f%96%e5%be%97%e3%81%ae%e6%94%b9%e5%96%84/#post-87399</guid>
                    </item>
							        </channel>
        </rss>
		