Código para generar dos estilos de post

  • Autor Autor sebasxnco
  • Fecha de inicio Fecha de inicio
S

sebasxnco

Épsilon
hola que tal amigos, tengo una duda tengo el siguiente código para generar dos estilos de post o al menos eso creo quiero logro algo como lo de la imagen

http://twitpic.com/5zomkf/full

sitio web de la imagen Skatter Tech

PHP:
<div class="hubtitle"> <a title="Películas, Muisca, Series, TV, Canales…" href="http://sitio.com/categoria/entretenimeinto/"> <span>Entretenimiento</span> <span class="viewall">Ver...</span> </a></div>

                    <?php
    $my_query = new WP_Query('cat=3, 10, 6, 7, 9, 9&offset=0&showposts=1');
    while ($my_query->have_posts()) : $my_query->the_post();
?>
<div class="previewitem"> 
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><img width="312" height="125" src="<?php echo get_post_meta($post->ID, "Image", true);?>" class="attachment-gallery wp-post-image"></a>
</div>

<div class="largeitem"> 
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</div>
<?php endwhile; ?>	

<ul>

                    <?php
    $my_query = new WP_Query('cat=3, 10, 6, 7, 9, 9&offset=1, 2, 3, 4, 5&showposts=5');
    while ($my_query->have_posts()) : $my_query->the_post();
?>
<li class="smallitem"> <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>	

</ul>

señores que pena ya solucione el codigo para hacerlo por si alguien quiere es


PHP:
<div class="hubtitle"> <a title="Películas, Muisca, Series, TV, Canales…" href="http://sitio.com/categoria/entretenimeinto/"> <span>Entretenimiento</span> <span class="viewall">Ver...</span> </a></div>

                    <?php
    $my_query = new WP_Query('cat=3, 10, 6, 7, 9, 9&offset=1&showposts=1');
    while ($my_query->have_posts()) : $my_query->the_post();
?>
<div class="previewitem"> 
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><img width="312" height="125" src="<?php echo get_post_meta($post->ID, "Image", true);?>" class="attachment-gallery wp-post-image"></a>
</div>

<div class="largeitem"> 
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</div>
<?php endwhile; ?>	

<ul>

                    <?php
    $my_query = new WP_Query('cat=3, 10, 6, 7, 9, 9&offset=2&showposts=5');
    while ($my_query->have_posts()) : $my_query->the_post();
?>
<li class="smallitem"> <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>	

</ul>
 
para empezar offset tiene como argumento un número únicamente, el desplazamiento desde 0. Si quieres que no aparezca el primer post, debes usar 1. Si quieres que aparezca a partir del tercero, usa 2, etc.

Y la otra es que después de usar el wp_query debes hacer un reset de la consulta...


En mi opinión, con un contador, el segundo loop no es necesario. Pero esa es solo mi opinión.
 
Atrás
Arriba