C
codigoadicto
Beta
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
//obtengo primero los post en este caso todos
<?php query_posts( 'posts_per_page=-1' ); ?>
//el loop
<?php while (have_posts()) : the_post(); ?>
//obteniendo el thumbnail del post pasandole una dimension especifica
<?php the_post_thumbnail( array(100,100) ); ?>
//obteniendo el enlace permanente y el titulo
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php endwhile; ?>
the_post_thumbnail('thumbnail'); // Thumbnail (default 150px x 150px max)
the_post_thumbnail('medium'); // Medium resolution (default 300px x 300px max)
the_post_thumbnail('large'); // Large resolution (default 640px x 640px max)
the_post_thumbnail('full'); // Full resolution (original size uploaded)
Este código muestra como obtener el Thumbnail de un post o varios post como en este caso, siempre y cuando el post cuente con alguna imagen.
PHP://obtengo primero los post en este caso todos <?php query_posts( 'posts_per_page=-1' ); ?> //el loop <?php while (have_posts()) : the_post(); ?> //obteniendo el thumbnail del post pasandole una dimension especifica <?php the_post_thumbnail( array(100,100) ); ?> //obteniendo el enlace permanente y el titulo <a rel="nofollow" href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php endwhile; ?>
//obtengo primero los post en este caso todos
<?php query_posts( 'posts_per_page=-1' ); ?>
//el loop
<?php while (have_posts()) : the_post(); ?>
<a rel="nofollow" href="<?php the_permalink(); ?>"><?php
//Verificamos si el post tiene un thumb añadido
if(has_post_thumbnail()){
//lo mostramos
the_post_thumbnail( array(100,100) );
}else{
//sino tiene mostramos uno por defecto
echo '<img src="'.get_template_directory_uri().'/images/xdefecto.jpg" class="attachment-post-thumbnail wp-post-image">';
}
?></a>
<a rel="nofollow" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php endwhile; ?>
Y si quiero mostrar solo 4 post?
<?php query_posts( 'posts_per_page=-1&showposts=4' ); ?>
Y si quiero mostrar solo 4 post?
Me uno a la pregunta
<?php query_posts( 'posts_per_page=4' ); ?>
Utilizamos cookies y tecnologías similares para los siguientes fines:
¿Aceptas las cookies y estas tecnologías?
Utilizamos cookies y tecnologías similares para los siguientes fines:
¿Aceptas las cookies y estas tecnologías?