Ver Mensaje Individual
  #6 (permalink)  
Antiguo 10/01/2011, 05:01
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

Por si le sirve a alguien, eliminé el condicional del segundo loop y se lo puse al primero y funciona correctamente. Se elimina la posibilidad de que una búsqueda por categorías que no de resultados no muestre nada pero como es una guía, sólo se añade una categoría si existe contenido para la misma ya que los menús se crean dinámicamente, por lo tanto las categorías sin contenido no existen.

Salud!

Código PHP:
Ver original
  1. <!-- posts marcados como fijos -->
  2. <?php if (have_posts()) :
  3.    $sticky = get_option('sticky_posts');
  4.    $destacado = array(
  5.    'ignore_sticky_posts' => 1,
  6.      'post__in' => $sticky,
  7.      'cat' => $cat,
  8.      'posts_per_page' => 4
  9.    );
  10. query_posts($destacado);
  11. while (have_posts()) : the_post(); ?>
  12. <div class="vcard destacado">
  13. <h3 class="fn org" id="post-<?php the_ID(); ?>">
  14. <a href="<?php $values = get_post_custom_values("link-ext"); echo $values[0]; ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
  15. <?php the_content(); ?>
  16. </div>
  17. <?php endwhile; endif; ?>
  18.  
  19. <!-- los demás posts de la categoria exceptuando los marcados como fijos -->
  20. <ul id="listado">
  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.       'caller_get_posts'=> 1,
  28.       'cat' => $cat,
  29.       'showposts' => 6,
  30.     );
  31. query_posts($args);
  32. while (have_posts()) : the_post(); ?>
  33. <li class="vcard">
  34. <h4 class="fn org" id="post-<?php the_ID(); ?>">
  35. <a href="<?php $values = get_post_custom_values("link-ext"); echo $values[0]; ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h4>
  36. <?php the_content(); ?>
  37. </li>
  38. <?php endwhile; ?>
  39. </ul>
  40. <div class="navigation">
  41. <?php
  42. global $paged;
  43. if ( isset( $_GET['paged'] ) )
  44. $page = abs( (int) $_GET['paged'] );
  45. else
  46. $page = 1;
  47. $start = $offset = ( $page - 1 ) * 20;
  48. $page_links = paginate_links( array(
  49.     'base' => add_query_arg( 'paged', '%#%' ),
  50.     'format' => '',
  51.     'total' => $wp_query->max_num_pages,
  52.     'current' => $page
  53. ));
  54. if ( $page_links )
  55.     echo '<div class="paginacion">' .$page_links. '</div>'; ?>
  56. </div>