Support » How-To and Troubleshooting » Last comment of a category

Last comment of a category

  • Hello,

    i want to show a link with the last comment of a category.

    i have this code:

    $categories = get_all_category_ids();
    foreach($categories as $catid) {
    while (have_posts()) : the_post(); ?>
    <div style="float: left; width: 400px; border-top: 2px solid #800000;"><?php the_category(', ') ?><br /><?php $category = get_the_category(); echo $category[0]->category_description ; ?></div>
    <div style="float: left; width: 50px; border-top: 2px solid #800000;"><a href="<?php bloginfo('url'); ?>/category/<?php $category = get_the_category(); echo $category[0]->category_nicename ; ?>/feed" title="RSS"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rss.gif" alt="Flux RSS" /></a></div>
    <div style="float: left; width: 80px; border-top: 2px solid #800000;"><?php $category = get_the_category(); echo $category[0]->category_count; ?></div>
    <div style="float: left; border-top: 2px solid #800000;"><a href="<?php the_permalink(); ?>" title="Titre"><?php the_title(); ?></a><br />le <?php the_time('j/m') ?>, par <?php the_author(', ') ?></div>
    <div style="clear: both;"></div>
    <?php endwhile; }?>

    how to add a <div> for see the last comment of a category?


Viewing 3 replies - 1 through 3 (of 3 total)
  • I have the same problem width while() in index.php

    <?php while (have_posts()) : the_post(); ?>
    	<div class="entry">
    		<?php the_content(); ?>
    <?php endwhile; ?>

    …how can i mark last entry within this while()?

    <div class="entry">…</div>
    <div class="entry">…</div>
    <div class="entry last">…</div>

    I can’t believe that it’s the only solution

    Looks like it’s the solution. For me, at least:

    <?php while (have_posts()) : the_post(); ?>
    	<div class="entry<?php echo ($post == $posts[count($posts)-1]) ? ' last' : '' ?>">
    		<?php the_content(); ?>
    <?php endwhile; ?>

    Sorry, but what the relationship with my problem? lol

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Last comment of a category’ is closed to new replies.
Skip to toolbar