0

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.

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

<?php
while ($queryObject->have_posts()){
    $queryObject->the_post();
    ?>

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




<?php
}
?>
<?php wp_reset_postdata();
}
?>
6
  • please post the full code of your custom loop - all including the endif;
    – Michael
    Commented Jan 14, 2013 at 12:39
  • added, and it still doesn't work
    – Mihad Aiko
    Commented Jan 15, 2013 at 5:27
  • Are you certain you have posts in category #23? Try var_dump($queryObject); to see if there's anything there. Commented Jan 15, 2013 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
    Commented Jan 15, 2013 at 7:56
  • custom post types in a query: codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters
    – Michael
    Commented Jan 15, 2013 at 11:13

1 Answer 1

0

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' );
1
  • This doesn't work
    – Mihad Aiko
    Commented Jan 15, 2013 at 5:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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