View Full Version : query page

10-14-2009, 07:35 PM

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

10-14-2009, 08:33 PM
You need to know what the query_posts function expects. Tossing in random information rarely works.

10-14-2009, 08:40 PM
Thank you Tom,

How can I fix it? Shall we call the page-id right away instead of saying post_type=page?

Thank you very much

All the best

10-14-2009, 08:42 PM
Again, you need to know what the query_posts function expects.

10-14-2009, 08:45 PM
the query_posts expects page but how can I tell him to expect specific pages? sorry I am very newbie with PHP... I don't want to bother...

All the best


10-14-2009, 08:50 PM
Did you write the function? Do you have a function definition? Do you have any code at all? Do you have documentation for the function? You can't just throw anything into a function as an argument and expect it to work.

10-14-2009, 09:08 PM
Ah, you're great !!!! I tought it might be linked somehow... I attached the 2 original files and here is the code as I modified it thinking to make it work...

<!-- Featured Area -->
<div id="featured-area">
<div id="s1" class="pics">
<?php $ids = array();
query_posts(array('post_type' => 'page', 'page_id'=>329,17,12,7,18));
while (have_posts()) : the_post();
if (get_option('enews_grab_image') == 'Enable') { $thumb = catch_that_image(); }
else { $thumb = get_post_meta($post->ID, 'Thumbnail', $single = true); } ?>
<div style="width: 830px;">
<img src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php echo $thumb; ?>&amp;h=206&amp;w=510&amp;zc=1" alt="<?php echo(the_title()); ?>" width="510px" height="206px" />
<div class="featured-overlay"></div>

<h1><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title2('', '...', true, '30'); ?></a></h1>
<p><?php truncate_post(350); ?></p>
<?php $ids[]= $post->ID;
endwhile; wp_reset_query(); ?>
<!-- Featured posts thumbnails -->
<h3>A la Une</h3>
<div class="clear"></div>
<a id="prev-item" href="#">Prec</a>
<a id="next-item" href="#">Suiv</a>
</div> <!-- end featured area -->

Thank you for your precious input

All the best

10-14-2009, 09:13 PM
Neither of the files in the zip show the function definition for query_posts(). You'll need that function if you want to know how to use it and/or how to modify it to make it do what you want.

10-14-2009, 09:36 PM
i am using wordpress..

is it this one you think? Related to wordpress.

Thanks for your patience....

All the best

10-14-2009, 09:49 PM
The place to look for Wordpress function definitions is the Wordpress Plugin API (http://codex.wordpress.org/Plugin_API). The specific information for query_posts is here (http://codex.wordpress.org/Template_Tags/query_posts). Check out that page. Lots of useful information there.

I think the section you're interested in is titled "Post & Page Parameters". It's a little more than half way down the page. Not sure, though, since I don't use Wordpress and can't test with anything.

Also, I ran across this page (http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query). Not sure if there's anything there you can use.

10-14-2009, 09:59 PM
Thank you very much... I'll digg into it...

I let you know what comes out.

All the best