Deano
Deano

Reputation: 12200

wordpress shortcode query

I'm a system admin, and I have very little knowledge in php, hoping to find help here.

I have the following shortcode from my wordpress blog

$wp_query = new WP_Query(array(
        'post_type' => array('page'),
        'showposts' => $limit,
        'orderby' => $orderby,
        'order' => $order
));

Currently this shortcode is listing all pages, there is a way that I could set in the array specific page IDs?

Upvotes: 1

Views: 179

Answers (2)

Nirmal Ram
Nirmal Ram

Reputation: 1732

Try this

 $include = array(1,3,8,98,13);
 $wp_query = new WP_Query(
        array(
            'post_type' => array('page'),
            'showposts' => $limit,
             'post__in'=>$include,
            'orderby' => $orderby,
            'order' => $order));

where $include is an array of the pages you wish to include.

Upvotes: 1

educolo
educolo

Reputation: 894

You should try this

$wp_query = new WP_Query(
array(
    'post_type' => array('page'),
    'post__in' => array( 2, 5, 12, 14, 20 ),
    'showposts' => $limit,
    'orderby' => $orderby,
    'order' => $order

If you need more help you can search in wp_query documentation

Upvotes: 1

Related Questions