¿Cómo llamar un post personalizado con get_posts() en lugar de query_posts()?
Actualmente uso query_posts
para mostrar estos posts personalizados pero estoy bastante seguro de que debería usar get_posts()
para escribirlo correctamente.
<?php query_posts( array( 'type-mario' => 'games', 'showposts' => 10 ) ); ?>
<p>Juegos de 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(); ?>
Gracias por tu consejo.
Hola Elium2009:
Usando tu código, creo que esto es lo que estabas buscando? (ten en cuenta que WP_Query()
es simplemente la versión más directa de get_posts()
):
<?php $posts = WP_Query(array(
'taxonomy' => 'type-mario'
'term' => 'games',
'posts_per_page' => 10
)); ?>
<p>Juegos de 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(); ?>
¿Espero que esto te ayude?

Gracias, pero me gustaría obtenerlo desde mi taxonomía personal asociada a mi custom-post, aquí type-mario es mi taxonomía asociada a un custom-post y games su término. ¿Cómo lo harías?

¿Intentaste agregar la taxonomía y el término en el código anterior?<?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; ?>
