Ver Mensaje Individual
  #5 (permalink)  
Antiguo 25/09/2010, 10:35
Roberikom
 
Fecha de Ingreso: septiembre-2005
Mensajes: 21
Antigüedad: 18 años, 7 meses
Puntos: 0
Respuesta: Mostrar contenidos en el index

La plantilla venia con esa función, pero para una sola categoría, lo que yo hice fue replicar e código para mostrar el numero de categorías que yo quería y no solo una...



el código del index es este:
Código PHP:
<?php get_header(); ?>

<div id="content"> 
<? include(TEMPLATEPATH."/featured.php"); ?>

        <div class="home-entry">
<h2>Últimos Artículos </h2>
    <?php if (have_posts()) : while (have_posts()) : the_post();
if( 
$post->ID == $do_not_duplicate ) continue;  ?>

        <div class="post" id="post-<?php the_ID(); ?>">

            <h1><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h1>


        <div class="meta">
       Fecha: <?php the_time('l j F Y'?>
        </div>
            <?php the_excerpt(); ?>            
<span class="read">               
<a href="<?php echo get_permalink(); ?>" >Continuar Leyendo...</a>
</span>

                <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ''after' => '</p>''next_or_number' => 'number')); ?>

        

            </div>
    


    <?php endwhile; else: ?>
  
<?php endif; ?>
        <div class="navigation">
            <?php wp_pagenavi(); ?>
        </div>


    </div>
<? include(TEMPLATEPATH."/news.php"); ?>

</div>



<div id="right">
<? include(TEMPLATEPATH."/banner.php"); ?>

<? include(TEMPLATEPATH."/tabs.php"); ?>

<?php get_sidebar(); ?>

</div>

<?php get_footer(); ?>
y el de la función "new" a la que hace referencia (y se encarga de mostrar las entradas por categorías) es este:

Código PHP:
<div class="news">
<h2>Destacados</h2>
<div class="news-entry">
<?php $my_query = new WP_Query('showposts=1&cat=9');
while (
$my_query->have_posts()) : $my_query->the_post();
if ( 
$post->ID == $do_not_duplicate ) continue;
update_post_caches($posts);
$do_not_duplicate $post->ID?>



                        <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
<div class="thumb-main">


<?php $image get_post_meta($post->ID'thumbnail'true); ?>
<?php $link 
get_post_meta($post->ID'link'true); ?>
<a href="<?php echo $link?>"><img src="<?php echo $image?>" alt="" /></a>

</div>
            <div class="postmeta"><span class="date"><?php the_time('j M Y'?></span> </div>
                            <div class="post" id="post-<?php the_ID(); ?>"><br />
    


                                <?php the_excerpt(); ?>
                                   



</div>
                               


<?php endwhile; ?>         
      </div>
</div>

<div class="news">
<h2>Tres</h2>
<div class="news-entry">
<?php $my_query = new WP_Query('showposts=1&cat=11');
while (
$my_query->have_posts()) : $my_query->the_post();
if ( 
$post->ID == $do_not_duplicate ) continue;
update_post_caches($posts);
$do_not_duplicate $post->ID?>



                        <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
<div class="thumb-main">


<?php $image get_post_meta($post->ID'thumbnail'true); ?>
<?php $link 
get_post_meta($post->ID'link'true); ?>
<a href="<?php echo $link?>"><img src="<?php echo $image?>" alt="" /></a>

</div>
            <div class="postmeta"><span class="date"><?php the_time('j M Y'?></span> </div>
                            <div class="post" id="post-<?php the_ID(); ?>"><br />
    


                                <?php the_excerpt(); ?>
                                   



</div>
                               


<?php endwhile; ?>         
      </div>
      </div>


<div class="news">
<h2>Cinco</h2>
<div class="news-entry">
<?php $my_query = new WP_Query('showposts=1&cat=13');
while (
$my_query->have_posts()) : $my_query->the_post();
if ( 
$post->ID == $do_not_duplicate ) continue;
update_post_caches($posts);
$do_not_duplicate $post->ID?>



                        <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
<div class="thumb-main">


<?php $image get_post_meta($post->ID'thumbnail'true); ?>
<?php $link 
get_post_meta($post->ID'link'true); ?>
<a href="<?php echo $link?>"><img src="<?php echo $image?>" alt="" /></a>

</div>
            <div class="postmeta"><span class="date"><?php the_time('j M Y'?></span> </div>
                            <div class="post" id="post-<?php the_ID(); ?>"><br />
    


                                <?php the_excerpt(); ?>
                                   



</div>
                               


<?php endwhile; ?>         
      </div>
      </div>
<div class="news">
<h2>Dos</h2>
<div class="news-entry">
<?php $my_query = new WP_Query('showposts=1&cat=10');
while (
$my_query->have_posts()) : $my_query->the_post();
if ( 
$post->ID == $do_not_duplicate ) continue;
update_post_caches($posts);
$do_not_duplicate $post->ID?>



                        <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
<div class="thumb-main">


<?php $image get_post_meta($post->ID'thumbnail'true); ?>
<?php $link 
get_post_meta($post->ID'link'true); ?>
<a href="<?php echo $link?>"><img src="<?php echo $image?>" alt="" /></a>

</div>
            <div class="postmeta"><span class="date"><?php the_time('j M Y'?></span> </div>
                            <div class="post" id="post-<?php the_ID(); ?>"><br />
    


                                <?php the_excerpt(); ?>
                                   



</div>
                               


<?php endwhile; ?>         
      </div>
      </div>


<div class="news">
<h2>Uno</h2>
<div class="news-entry">
<?php $my_query = new WP_Query('showposts=1&cat=5');
while (
$my_query->have_posts()) : $my_query->the_post();
if ( 
$post->ID == $do_not_duplicate ) continue;
update_post_caches($posts);
$do_not_duplicate $post->ID?>



                        <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
<div class="thumb-main">


<?php $image get_post_meta($post->ID'thumbnail'true); ?>
<?php $link 
get_post_meta($post->ID'link'true); ?>
<a href="<?php echo $link?>"><img src="<?php echo $image?>" alt="" /></a>

</div>
            <div class="postmeta"><span class="date"><?php the_time('j M Y'?></span> </div>
                            <div class="post" id="post-<?php the_ID(); ?>"><br />
    


                                <?php the_excerpt(); ?>
                                   



</div>
                               


<?php endwhile; ?>         
      </div>
      </div>
SI te fijas en "new"
Código PHP:
<?php $my_query = new WP_Query('showposts=1&cat=5');
sale la opción de cuantas entradas mostrar (en mi caso 1) y la id de la categoría


por otro lado
Código PHP:
<div class="thumb-main">


<?php $image get_post_meta($post->ID'thumbnail'true); ?>
<?php $link 
get_post_meta($post->ID'link'true); ?>
<a href="<?php echo $link?>"><img src="<?php echo $image?>" alt="" /></a>

</div>
es la opción para mostrar imagenes (thumb) a cada entrada