Forums

[resolved] specific pages (8 posts)

  1. ppoivre
    Member
    Posted 2 years ago #

    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

  2. superiorstudio
    Member
    Posted 2 years ago #

    Dunno if it is this simple, but you seem to be missing a closing quotation mark at the end of the page id numbers.

  3. ppoivre
    Member
    Posted 2 years ago #

    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...

  4. ppoivre
    Member
    Posted 2 years ago #

    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

  5. superiorstudio
    Member
    Posted 2 years ago #

    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?

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

  6. ppoivre
    Member
    Posted 2 years ago #

    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!

  7. ppoivre
    Member
    Posted 2 years ago #

    This was the answer...

    <?php $ids = array();
    query_posts(array('post_type' => 'page', 'post__in' => array(329,17,19,7)));
  8. Kastaniet
    Member
    Posted 1 year ago #

    Try to find an answer here: php tutorials.

Topic Closed

This topic has been closed to new replies.

About this Topic