mardi 3 février 2015

List post categories that link to a page showing those posts


I have posts with different categories.


I have a blog page that lists the posts like this.



<?php

$blog_args = array(

'post_type' => 'post',
'order_by' => 'date',
'order' => 'ASC'
);

$blog_loop = new WP_Query($blog_args);

if($blog_loop->have_posts()):
while($blog_loop->have_posts()):
$blog_loop->the_post();
?>


<div class="row">

<div class="col-sm-3 img-responsive">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail('post-thumbnail', array( 'class' => "img-responsive"));
}
?>
</div>
<div class="col-sm-9">

<h3><?php echo the_title(); ?></h3>
<p><?php echo the_content(); ?></p>

</div>

</div>


<?php endwhile; endif; ?>

<?php wp_reset_postdata(); ?>


I would like to have a list of the different categories on the blog page. If I click the category I would like to show the post with that catogory.


I can list the categories like so.



<ul>
<?php
wp_list_categories('title_li=>');
?>
</ul>


If I click the link it takes me to an empty page with the name of the category in the URL.


How can I list the categories and link to show the post with that category.





Aucun commentaire:

Enregistrer un commentaire