Ver Mensaje Individual
  #5 (permalink)  
Antiguo 07/01/2011, 12:41
AlbertoGarcia
 
Fecha de Ingreso: mayo-2009
Ubicación: Fuerteventura
Mensajes: 324
Antigüedad: 15 años
Puntos: 19
Respuesta: Mostrar posts por tipo dentro de una página de categoría

Pues he tenido que volver, porque el código que puse arriba no funciona si la categoría no tiene ningún post fijo. Le he dado mil vueltas y no consigo que cuando el primer loop no encuentre ningún post fijo, el segundo funcione. Dejo aquí el código y la referencia del codex que estoy usando: http://codex.wordpress.org/Function_...ost_Parameters

¿Alguna idea?

Gracias a todos de antemano,

Salud!

Código PHP:
Ver original
  1. <!-- Este primer loop muestra los posts de la categoría marcados como fijos -->
  2. <?php
  3.    $sticky = get_option('sticky_posts');
  4.    $destacado = array(
  5.         'post__in' => $sticky,
  6.     'ignore_sticky_posts' => 1
  7.         'cat' => $cat,
  8.     'showposts' => 4,
  9.    );
  10.    query_posts($destacado);
  11.    while (have_posts()) : the_post(); ?>
  12. <div class="fijo">
  13. <h3><?php the_title(); ?></h3>
  14. <?php the_content(); ?>
  15. </div>
  16. <?php endwhile; ?>
  17.  
  18. <ul id="listado">
  19. <!-- Este loop muestra los demás posts exceptuando los marcados como fijos -->
  20. <?php if (have_posts()) : ?>
  21.   <?php
  22.     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  23.     $sticky = get_option('sticky_posts');
  24.     $args = array(
  25.         'post__not_in' => $sticky,
  26.         'paged' => $paged,
  27.         'cat' => $cat,
  28.     'showposts' => 6,
  29.     );
  30.     query_posts($args); ?>
  31.     <?php while (have_posts()) : the_post(); ?>
  32. <li class="normal">
  33. <h4><?php the_title(); ?></h4>
  34. <?php the_content(); ?>
  35. </li>
  36. <?php endwhile; ?>
  37. <div class="navigation">
  38. </div>
  39. <?php else : ?>
  40. <p><?php _e('Lo siento, no encontre nada para mostrar.'); ?></p>
  41. <?php endif; ?>
  42. </ul>