{"id":1611865,"date":"2010-08-03T20:40:36","date_gmt":"2010-08-03T20:40:36","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/post-list-on-category-page\/"},"modified":"2016-08-19T18:56:37","modified_gmt":"2016-08-19T18:56:37","slug":"post-list-on-category-page","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/post-list-on-category-page\/","title":{"rendered":"Post list on category page"},"content":{"rendered":"<p>I am trying to get a list of the post within a category which I have done but I want it to only show 3 of the post titles and then have a link for View All under that will link to all of that sub categories posts. The code I have used is below.<\/p>\n<p>Thanks<\/p>\n<p>&lt;?php<br \/>\n \t\t$cat_name = get_the_title();<br \/>\n\t\t$cat_id = get_cat_id($cat_name);<br \/>\n \t\t$categories=  get_categories(&#8216;child_of=&#8217;.$cat_id);<br \/>\n  \t\t\tforeach ($categories as $cat) {<br \/>\n  \t\t\t$cat_link = get_category_link($cat-&gt;cat_ID);<br \/>\n  \t\t\techo &#8216;&lt;div class=&#8221;region&#8221;&gt;&lt;h3&gt;<a href=\"'.$cat_link.'\">&#8216;;<br \/>\n\t\t\techo $cat-&gt;cat_name;<br \/>\n\t\t\techo &#8216;<\/a>&lt;\/h3&gt;<\/p>\n<ul>&#8216;;<br \/>\n\t\t\tquery_posts(&#8216;cat=&#8217;.$cat-&gt;cat_ID.&#8217;&amp;showposts=3&#8242;);<br \/>\n\t\t\t\twhile (have_posts()) : the_post(); $permalink = get_permalink($post-&gt;ID);<br \/>\n\t\t\t\techo &#8216;<\/p>\n<li>&lt;a href=&#8221;&#8216;;<br \/>\n\t\t\t\techo $permalink.'&#8221;&gt;&#8217;;<br \/>\n\t\t\t\techo the_title();<br \/>\n\t\t\t\techo &#8216;<\/li>\n<p>&#8216;;<br \/>\n\t\t\t\tendwhile;<br \/>\n\techo &#8216;<\/ul>\n<p>&#8216;;<\/p>\n<p>\techo &#8216;&lt;\/div&gt;&#8217;;<br \/>\n  }<br \/>\n ?&gt;<\/p>\n","protected":false},"template":"","class_list":["post-1611865","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/1611865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/1611865\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=1611865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}