• Resolved wpfan1000

    (@wpfan1000)


    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

    (@keesiemeijer)

    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

    (@wpfan1000)

    Hi keesiemeijer,

    Thank you very much for your response.

    I will try your suggestions shortly.

    Thread Starter wpfan1000

    (@wpfan1000)

    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.