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
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.
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...
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
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
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!
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)));
Kastaniet
Member
Posted 1 year ago #
Try to find an answer here: php tutorials.