How to call a custom post with get_posts() instead of query_posts()?

Hi Elium2009:

Using your code, I think this is what you were looking for? (note that WP_Query() is just the more direct version of get_posts()):

<?php $posts = WP_Query(array( 
   'taxonomy' => 'type-mario'
   'term' => 'games',
   'posts_per_page' => 10 
)); ?>
<p>Mario games</p>
<?php while ( $posts->have_posts() ) : $posts->the_post(); ?>
  <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <h2><?php the_title(); ?></h2>
  </div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>

Hope this helps?

Leave a Comment