Title: Parameter in function in shortcode not working
Last modified: August 21, 2016

---

# Parameter in function in shortcode not working

 *  Resolved [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * (@wpfan1000)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/parameter-in-function-in-shortcode-not-working/)
 * Hi,
 * I have the following code for a shortcode:
 *     ```
       function myrelatedpages ( $atts, $content = null )
       {
       extract( shortcode_atts( array(
       'pageids' => '', // Set default values
       ), $atts ) );
   
       $html = wp_list_pages('title_li=&echo=0&sort_column=menu_order&include=$pageids');
   
       return $html;
       }
   
       add_shortcode('myrelatedpages', 'myrelatedpages');
       ```
   
 * // usage: [myrelatedpages pageids=”5,6″]
 * The problem is that the $pageids is not being accepted in the wp_list_pages function,
   ie include=$pageids does not work.
 * The function does not output anything.
 * I have tested that $pageids does contain a value, eg: 2553 (a page id) and I 
   have checked that hard coding works eg: include=2553.
 * Any help would be much appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/parameter-in-function-in-shortcode-not-working/#post-4186380)
 * Try changing this:
 *     ```
       $html = wp_list_pages('title_li=&echo=0&sort_column=menu_order&include=$pageids');
       ```
   
 * to this:
 *     ```
       $html = wp_list_pages( "title_li=&echo=0&sort_column=menu_order&include=$pageids" );
       ```
   
 * or this:
 *     ```
       $html = wp_list_pages( 'title_li=&echo=0&sort_column=menu_order&include=' . $pageids );
       ```
   
 *  Thread Starter [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * (@wpfan1000)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/parameter-in-function-in-shortcode-not-working/#post-4186656)
 * Hi keesiemeijer,
 * Thank you very much for your response.
 * I will try your suggestions shortly.
 *  Thread Starter [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * (@wpfan1000)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/parameter-in-function-in-shortcode-not-working/#post-4186674)
 * Hi keesiemeijer,
 * wp_list_pages(‘title_li=&echo=0&sort_column=menu_order&include=’.$pageids);
 * works!!!
 * Thanks very much for your help!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Parameter in function in shortcode not working’ is closed to new replies.

## Tags

 * [shortcode parameters](https://wordpress.org/support/topic-tag/shortcode-parameters/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/parameter-in-function-in-shortcode-not-working/#post-4186674)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
