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

[SOLUCIONADO] titulos con texto y numeracion delante

Estas en el tema de titulos con texto y numeracion delante en el foro de WordPress en Foros del Web. quiero hacer una lista con los titulos de los post y añadireles "tema x" delante. Lo he intentado con css: @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código CSS: Ver ...
  #1 (permalink)  
Antiguo 08/02/2013, 15:33
laura_moreno14
Invitado
 
Mensajes: n/a
Puntos:
titulos con texto y numeracion delante

quiero hacer una lista con los titulos de los post y añadireles "tema x" delante.

Lo he intentado con css:
Código CSS:
Ver original
  1. h3::before { content: "Tema " counter(tema) ": "; counter-increment: tema;}

Y tambien con php:
Código PHP:
Ver original
  1. <?php global $query_string; ?>
  2. <?php query_posts( $query_string . '&order=ASC&posts_per_page=50&tag=herencia&post_status=publish, future' ); while ( have_posts() ) : the_post(); ?>
  3. <?php $c = 1 ?>
  4. <?php if ($post->post_status == 'future'): ?>
  5. <h3><?php the_title("tema $c"); ?></h3>
  6.        <?php else : ?>
  7. <h3><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title("tema $c"); ?></a></h3>
  8.  <?php $c++?>
  9. <?php endif ; ?>
  10. <?php endwhile; wp_reset_query();?>

El caso es que aparece todo bien menos que no aumenta la numeracion, aparece siempre 1. Me pasa de las dos formas y por eso creo que lo que esta mal es el loop. Pero no se cual es el problema, alguien sabe que puede estar ocurriendo?

muchas gracias espero que alguien pueda ayudarme
  #2 (permalink)  
Antiguo 08/02/2013, 20:02
 
Fecha de Ingreso: abril-2003
Mensajes: 1.129
Antigüedad: 20 años, 11 meses
Puntos: 34
Respuesta: titulos con texto y numeracion delante

Bueno, no lo he probado, pero si dices que el PHP funcionó, el error está acá:

Estás dejando del $c = 1 dentro del while, por lo que cada vez que se ejecuta el while, el $c vuelve a ser 1

Cambia:

Código PHP:
Ver original
  1. <?php global $query_string; ?>
  2.     <?php query_posts( $query_string . '&order=ASC&posts_per_page=50&tag=herencia&post_status=publish, future' ); while ( have_posts() ) : the_post(); ?>
  3.     <?php $c = 1 ?>
  4.     <?php if ($post->post_status == 'future'): ?>
  5.     <h3><?php the_title("tema $c"); ?></h3>
  6.            <?php else : ?>
  7.     <h3><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title("tema $c"); ?></a></h3>
  8.      <?php $c++?>
  9.     <?php endif ; ?>
  10.     <?php endwhile; wp_reset_query();?>

Por:

Código PHP:
Ver original
  1. <?php $c = 1 ?>
  2. <?php global $query_string; ?>
  3.     <?php query_posts( $query_string . '&order=ASC&posts_per_page=50&tag=herencia&post_status=publish, future' ); while ( have_posts() ) : the_post(); ?>
  4.  
  5.     <?php if ($post->post_status == 'future'): ?>
  6.     <h3><?php the_title("tema $c"); ?></h3>
  7.            <?php else : ?>
  8.     <h3><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title("tema $c"); ?></a></h3>
  9.      <?php $c++?>
  10.     <?php endif ; ?>
  11.     <?php endwhile; wp_reset_query();?>

Imagino que debería funcionar.

PD: Esas lineas donde aparece $c = 1 y la de $c++, no deberían llevar también el ; al final?
__________________
elGastronomo
  #3 (permalink)  
Antiguo 09/02/2013, 06:58
laura_moreno14
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: titulos con texto y numeracion delante

Gracias! me funciona perfecto!

Etiquetas: numeracion, php, post, tema, titulos
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 06:15.