{"id":1665108,"date":"2010-09-09T17:42:53","date_gmt":"2010-09-09T17:42:53","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/how-do-i-finish-this-function\/"},"modified":"2016-08-19T19:30:48","modified_gmt":"2016-08-19T19:30:48","slug":"how-do-i-finish-this-function","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/how-do-i-finish-this-function\/","title":{"rendered":"How do I finish this function?"},"content":{"rendered":"<p>Howdy wordpressers!<\/p>\n<p>I&#8217;m a bit stuck. My php isn&#8217;t that amazing but I have managed to cobble together the basics of a function to show a specific number of posts from a specific category on a apge, using a shortcode.<\/p>\n<p>Here is my php wizardry so far &#8211;<\/p>\n<pre><code>\/\/ Show posts shortcode\nfunction scShowPosts($atts) {\n    extract(shortcode_atts(array(\n        &#039;category&#039; =&gt; 0,\n        &#039;number&#039; =&gt; 0\n    ), $atts));\n\n    return &quot;Hello World&lt;br \/&gt;&quot; . $category . &quot;&lt;br \/&gt;&quot; . $number . &quot;&lt;br \/&gt;&quot;;\n\n    query_posts(&#039;category_name=&#039; . $category . &#039;&amp;number=&#039; . $number );\n    while (have_posts()) : the_post();\n\n    \/\/ What goes here?\n\n    endwhile;\n}\n\nadd_shortcode(&quot;showposts&quot;, &quot;scShowPosts&quot;);<\/code><\/pre>\n<p>Now, I&#8217;m not sure if some sort of version of &#8216;the loop&#8217; will fit in there or not, or even if that would work from the functions.php file.<\/p>\n<p>Can anyone give me a poke in the right direction?<\/p>\n<p>Thanks \ud83d\ude09<\/p>\n","protected":false},"template":"","class_list":["post-1665108","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/1665108","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\/1665108\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=1665108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}