Come chiamare un custom post con get_posts() invece di query_posts()?
Attualmente uso query_posts
per mostrare questi custom post ma sono abbastanza sicuro che dovrei usare get_posts()
per scriverlo correttamente.
<?php query_posts( array( 'type-mario' => 'games', 'showposts' => 10 ) ); ?>
<p>Giochi Mario</p>
<?php while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2><?php the_title(); ?></h2>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
Grazie per il vostro consiglio.

Ciao Elium2009:
Utilizzando il tuo codice, penso che questo sia quello che stavi cercando? (nota che WP_Query()
è semplicemente la versione più diretta di get_posts()
):
<?php $posts = WP_Query(array(
'taxonomy' => 'type-mario'
'term' => 'games',
'posts_per_page' => 10
)); ?>
<p>Giochi di Mario</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(); ?>
Spero sia utile?

Grazie, ma vorrei ottenerlo dalla mia tassonomia personalizzata associata al mio custom-post, qui type-mario è la mia tassonomia associata a un custom-post e games è il termine. Come lo faresti?

Hai provato ad aggiungere la tassonomia e il termine nel codice sopra?<?php query_posts('post_type=games&posts_per_page=10&taxonomy=type_mario&term=games'); ?>
<?php if(have_posts()) : while (have_posts() ) : the_post(); ?>
...
<?php endwhile; endif; ?>
