Foros del Web » Creando para Internet » Sistemas de gestión de contenidos » WordPress »

Modificando plantilla wordpress - fichero index.php

Estas en el tema de Modificando plantilla wordpress - fichero index.php en el foro de WordPress en Foros del Web. Hola, estoy trabajando en una web de noticias y cultura en general, he comenzado trabajando con wordpress y una plantilla gratuita, la he ido modificando ...
  #1 (permalink)  
Antiguo 05/08/2012, 19:32
 
Fecha de Ingreso: agosto-2012
Mensajes: 1
Antigüedad: 11 años, 8 meses
Puntos: 0
Modificando plantilla wordpress - fichero index.php

Hola, estoy trabajando en una web de noticias y cultura en general, he comenzado trabajando con wordpress y una plantilla gratuita, la he ido modificando y hasta ahora voy bien, pero en el index hay una secuencia que construye unos div en donde van apareciendo las ultimas entradas publicadas, originalmente eran solo 2 div que exponian las ultimas entradas, pero yo he copiado el codigo y lo he repetido 12 veces de manera de tener 12 div con las ultimas entradas, ademas he modificado el CSS de forma de diagramarlo mejor... el asunto es que solo me aparecen solo las 3 ultimas entradas y en los restantes 9 div me repite la ultima entrada...
paso a exponerles el codigo ya modificado, si es que me pueden ayudar
gracias.
nota: he debido acortar el codigo hasta el div nº5 porque me pasaba en la cantidad de caracteres admitidos por el foro, pero creo se entiende la idea.

Código PHP:
<?php get_header(); ?>


<div id="content">

<?php include (TEMPLATEPATH '/slide.php'); ?>    

<div class="high-box lbox"> <!-- #################  highlight category-1 #################### -->
<?php $high_cat1 get_option('repo_high_cat1'); ?>
<h2 class="high-cat"><?php echo $high_cat1  ?>

</h2>
<?php $i 1;?>
<?php
$high_cat1 
get_option('repo_high_cat1');
$high_query = new WP_Query'category_name='.$high_cat1.'&posts_per_page=8' );
while ( 
$high_query->have_posts() ) : $high_query->the_post();
?>
<?php 
if($i == 1):?>

<div class="high-first-item">
<img class="highmage" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&amp;h=91&amp;w=146&amp;zc=1" alt="" />
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <?php wpe_excerpt('wpe_excerptlength_slide''wpe_excerptmore'); ?>
</div>

<?php elseif($i 100 ):?>

<div class="high-rest-item">
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php echo short_title('...'5); ?></a></h3>
</div>
 <?php endif; ?>

 <?php $i++; ?>
<?php 
endwhile; ?>

</div>




<div class="high-box lbox"> <!-- #################  highlight category-2 #################### -->
<?php $high_cat2 get_option('repo_high_cat2'); ?>
<h2 class="high-cat"><?php echo $high_cat2 ?></h2>
<?php $i 2;?>
<?php
$high_cat2 
get_option('repo_high_cat2');
$high_query = new WP_Query'category_name='.$high_cat2.'&posts_per_page=8' );
while ( 
$high_query->have_posts() ) : $high_query->the_post();
?>
<?php 
if($i == 2):?>

<div class="high-first-item">
<img class="highmage" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&amp;h=91&amp;w=146&amp;zc=1" alt="" />
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <?php wpe_excerpt('wpe_excerptlength_slide''wpe_excerptmore'); ?>
</div>

<?php elseif($i 100 ):?>

<div class="high-rest-item">
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php echo short_title('...'5); ?></a></h3>
</div>
 <?php endif; ?>

 <?php $i++; ?>
<?php 
endwhile; ?>

</div>




<div class="high-box lbox"> <!-- #################  highlight category-3 #################### -->
<?php $high_cat3 get_option('repo_high_cat3'); ?>
<h2 class="high-cat"><?php echo $high_cat3  ?>

</h2>
<?php $i 3;?>
<?php
$high_cat3 
get_option('repo_high_cat3');
$high_query = new WP_Query'category_name='.$high_cat3.'&posts_per_page=8' );
while ( 
$high_query->have_posts() ) : $high_query->the_post();
?>
<?php 
if($i == 3):?>

<div class="high-first-item">
<img class="highmage" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&amp;h=91&amp;w=146&amp;zc=1" alt="" />
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <?php wpe_excerpt('wpe_excerptlength_slide''wpe_excerptmore'); ?>
</div>

<?php elseif($i 100 ):?>

<div class="high-rest-item">
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php echo short_title('...'5); ?></a></h3>
</div>
 <?php endif; ?>

 <?php $i++; ?>
<?php 
endwhile; ?>

</div>



<div class="high-box lbox"> <!-- #################  highlight category-4 #################### -->
<?php $high_cat4 get_option('repo_high_cat4'); ?>
<h2 class="high-cat"><?php echo $high_cat4 ?></h2>
<?php $i 4;?>
<?php
$high_cat4 
get_option('repo_high_cat4');
$high_query = new WP_Query'category_name='.$high_cat4.'&posts_per_page=8' );
while ( 
$high_query->have_posts() ) : $high_query->the_post();
?>
<?php 
if($i == 4):?>

<div class="high-first-item">
<img class="highmage" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&amp;h=91&amp;w=146&amp;zc=1" alt="" />
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <?php wpe_excerpt('wpe_excerptlength_slide''wpe_excerptmore'); ?>
</div>

<?php elseif($i 100 ):?>

<div class="high-rest-item">
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php echo short_title('...'5); ?></a></h3>
</div>
 <?php endif; ?>

 <?php $i++; ?>
<?php 
endwhile; ?>

</div>



<div class="high-box rbox"> <!-- #################  highlight category-5 #################### -->
<?php $high_cat5 get_option('repo_high_cat5'); ?>
<h2 class="high-cat"><?php echo $high_cat5 ?></h2>
<?php $i 5;?>
<?php
$high_cat5 
get_option('repo_high_cat5');
$high_query = new WP_Query'category_name='.$high_cat5.'&posts_per_page=8' );
while ( 
$high_query->have_posts() ) : $high_query->the_post();
?>
<?php 
if($i == 5):?>

<div class="high-first-item">
<img class="highmage" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&amp;h=91&amp;w=146&amp;zc=1" alt="" />
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <?php wpe_excerpt('wpe_excerptlength_slide''wpe_excerptmore'); ?>
</div>

<?php elseif($i 100 ):?>

<div class="high-rest-item">
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php echo short_title('...'5); ?></a></h3>
</div>
 <?php endif; ?>

 <?php $i++; ?>
<?php 
endwhile; ?>

</div>


<div class="clear"></div>

<?php getpagenavi(); ?>


</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>
  #2 (permalink)  
Antiguo 06/08/2012, 07:57
Avatar de Nekko
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Buenos Aires
Mensajes: 3.141
Antigüedad: 16 años, 1 mes
Puntos: 656
Respuesta: Modificando plantilla wordpress - fichero index.php

No entiendo porqué repetís el bucle completo tantas veces. Pasemos en limpio, que estructura HTML querés generar? Con una vez que tires el loop con el contador ya podés ir usando condicionales sin necesidad de repetir consultas.

Te pongo algo a modo de ejemplo...

Código PHP:
Ver original
  1. <
  2. ?php $i = 1;
  3. $high_cat1 = get_option('repo_high_cat1');
  4. $high_query = new WP_Query( 'category_name='.$high_cat1.'&posts_per_page=8' );
  5. while ( $high_query->have_posts() ) : $high_query->the_post();
  6.  
  7. if($i == 1) { ?>
  8.  
  9. <div class="high-first-item">
  10. <img class="highmage" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&amp;h=91&amp;w=146&amp;zc=1" alt="" />
  11. <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
  12.     <?php wpe_excerpt('wpe_excerptlength_slide', 'wpe_excerptmore'); ?>
  13. </div>
  14. } if($i == 2) { ?>
  15.  
  16. // Tu código HTML para mostrar la entrada numero 2...
  17.  
  18. } if($i == 3) { ?>
  19.  
  20. // Tu código HTML para mostrar la entrada numero 3...
  21.  
  22. } if($i == 4) { ?>
  23.  
  24. // Tu código HTML para mostrar la entrada numero 4...
  25.  
  26. } if($i == 5) { ?>
  27.  
  28. // Tu código HTML para mostrar la entrada numero 5...
  29. // Bueno, creo que se entiende la idea xD
  30.  
  31. }
  32. //Sumamos...
  33. $i++;
  34. endwhile; endif; ?>
__________________
Taller para crear themes wordpress desde cero | Presupuestos para trabajos particulares vía MP

Etiquetas: modificar, themes
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:35.