Title: How do I finish this function?
Last modified: August 19, 2016

---

# How do I finish this function?

 *  [Chris](https://wordpress.org/support/users/chips/)
 * (@chips)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/how-do-i-finish-this-function/)
 * Howdy wordpressers!
 * I’m a bit stuck. My php isn’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.
 * Here is my php wizardry so far –
 *     ```
       // Show posts shortcode
       function scShowPosts($atts) {
           extract(shortcode_atts(array(
               'category' => 0,
               'number' => 0
           ), $atts));
   
           return "Hello World<br />" . $category . "<br />" . $number . "<br />";
   
           query_posts('category_name=' . $category . '&number=' . $number );
           while (have_posts()) : the_post();
   
           // What goes here?
   
           endwhile;
       }
   
       add_shortcode("showposts", "scShowPosts");
       ```
   
 * Now, I’m not sure if some sort of version of ‘the loop’ will fit in there or 
   not, or even if that would work from the functions.php file.
 * Can anyone give me a poke in the right direction?
 * Thanks 😉

 The topic ‘How do I finish this function?’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [Chris](https://wordpress.org/support/users/chips/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/how-do-i-finish-this-function/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
