• Resolved ppoivre

    (@ppoivre)


    Hi,

    Can anyone help me to refine this line of code?

    <?php $ids = array();
    query_posts(array('post_type' => 'page'));

    I would like to add some specific pages to query.

    I tried

    <?php $ids = array();
    query_posts(array('post_type' => 'page' 'page_id'='329,17,14,6));

    but it doesn’t work…

    Can anyone put me on the right track?

    Thanks in advance,

    All the best

Viewing 7 replies - 1 through 7 (of 7 total)
  • Dunno if it is this simple, but you seem to be missing a closing quotation mark at the end of the page id numbers.

    Thread Starter ppoivre

    (@ppoivre)

    Thanks,

    It’s logical but it doesn’t resolve the issue… with this code I get a T_CONSTANT_ENCAPSED_STRING error…

    Thanks for helping…

    Thread Starter ppoivre

    (@ppoivre)

    if I put that…

    <?php $ids = array();
    query_posts(array('post_type' => 'page', 'page_id'=>329,17,12,7,18));

    I get only the page id 329 displayed…. the other not !

    Any idea?

    Thank you very much

    All the best

    Sounds like what used to be called a type mismatch error, where you want the code to understand a number but it is seeing a string. Perhaps throwing an (int) in front of your number string as shown here?

    https://www.phpf1.com/tutorial/php-string-to-int.html

    Thread Starter ppoivre

    (@ppoivre)

    Thanks so much

    but writing this:

    <?php $ids = array();
    query_posts(array('post_type' => 'page', 'page_id'=> (int)'329,17,12,7,18'));

    didn’t help…

    mmmm!

    Thread Starter ppoivre

    (@ppoivre)

    This was the answer…

    <?php $ids = array();
    query_posts(array('post_type' => 'page', 'post__in' => array(329,17,19,7)));

    Try to find an answer here: php tutorials.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘specific pages’ is closed to new replies.