WordPress.org

Ready to get started?Download WordPress

Forums

Last comment of a category (4 posts)

  1. csseur3
    Member
    Posted 5 years ago #

    Hello,

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

    i have this code:

    <?php
    $categories = get_all_category_ids();
    foreach($categories as $catid) {
    query_posts("cat=$catid&showposts=1");
    while (have_posts()) : the_post(); ?>
    
    <div>
    
    <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>
    </div>
    <?php endwhile; }?>

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

    bye

  2. pepelsbey
    Member
    Posted 5 years ago #

    I have the same problem width while() in index.php

    <?php while (have_posts()) : the_post(); ?>
    	<div class="entry">
    		<?php the_content(); ?>
    	</div>
    <?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

  3. pepelsbey
    Member
    Posted 5 years ago #

    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(); ?>
    	</div>
    <?php endwhile; ?>
  4. csseur3
    Member
    Posted 5 years ago #

    Sorry, but what the relationship with my problem? lol

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.