WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the code below to display the latest post from a certain category but i am using Custom Post Types and I don't know how to insert the custom post type function into this code.

I want to get the latest post from a certain category, from each post type.

So how do i add that to the code below.

$queryObject = new  Wp_Query( 'posts_per_page=1&cat=23' );
// The Loop!
if ($queryObject->have_posts()) {

while ($queryObject->have_posts()){

<a href="<?php the_permalink(); ?>" title="<?php printf(__( 'Read %s', 'wpbx' ), wp_specialchars(get_the_title(), 1)) ?>">
                    <?php the_post_thumbnail('video-post');     ?>
     <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>

<?php wp_reset_postdata();
share|improve this question
please post the full code of your custom loop - all including the endif; – Michael Jan 14 '13 at 12:39
added, and it still doesn't work – Mihad Aiko Jan 15 '13 at 5:27
Are you certain you have posts in category #23? Try var_dump($queryObject); to see if there's anything there. – helgatheviking Jan 15 '13 at 6:00
Where do i put that, and yes there are post in category 23, I'm using custom post types as well, and I am using the categories in post types, could that be a cause of conflict – Mihad Aiko Jan 15 '13 at 7:56
custom post types in a query: codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters – Michael Jan 15 '13 at 11:13

showposts is replaced with posts_per_page (see Pagination Parameters). Also orderby value is invalid (see Order & Orderby Parameters).

$queryObject = new  Wp_Query( 'posts_per_page=1&cat=23' );
share|improve this answer
This doesn't work – Mihad Aiko Jan 15 '13 at 5:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.