Mostrar todas las publicaciones en la categoría actual
27 oct 2012, 09:39:27
Vistas: 15.2K
Votos: 1
Estoy buscando crear un comportamiento como el que se muestra en el siguiente enlace:
http://www.javaexperience.com/java-role-of-serialversionuid-in-serialization/
Aquí se muestran todas las publicaciones de la misma categoría. Actualmente está escrito manualmente en HTML, quiero replicar este comportamiento usando código PHP en mi single.php.
A continuación está el código que he escrito hasta ahora:
<?php
$category = get_the_category();
<ul>
query_posts('cat='.$category);
if ( have_posts() ) : while ( have_posts() ) : the_post();
<li><a href="get_permalink( $id );">the_title();</a></li>
endwhile; endif;
</ul>
<br/>
?>
¿Alguien puede ayudar a hacer que funcione?

Sandeep
177
Todas las respuestas a la pregunta
2
1
Prueba esto:
$cat = get_query_var('cat');
$PozCat = get_category ($cat);
$PozCat->id // nos da el ID de la categoría actual.
Luego usa este hook en tu consulta:
<ul>
<?php
$cat = get_query_var('cat');
$PozCat = get_category ($cat);
//$PozCat->id
query_posts('posts_per_page=-1&cat='.$PozCat->id);
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li><a href="<?php the_permalink();?>"><?php the_title(); ?></a></li>
<?php endwhile; endif; ?>
</ul>

Fatih Toprak
255
27 oct 2012 11:48:55
0
Puedes hacer esto usando Wp_query() pasando el nombre de la categoría como argumento:
<?php $my_query = new WP_Query('category_name=mi_categoria&showposts=-1'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<?php the_title(); ?></a>
<?php endwhile; ?>

swtshweta
432
27 oct 2012 11:36:27
Preguntas relacionadas