WordPress.org

Support

Support » How-To and Troubleshooting » PHP Code to add single comment to the loop

PHP Code to add single comment to the loop

  • I am using PHPexec to be able to run PHP code in my pages, not going to go into much detail on that.

    However, I need help, I have created a working loop that calls all of a categories posts to a page and displays the title and excerpt. I want to add to this loop to display a single most-recent comment for each title as well.

    Here is my existing code:

    <h1>The Forum</h1><br />
    <ul>
    <?php $recent = new WP_Query("cat=12&showposts=999"); while($recent->have_posts()) : $recent->the_post();?>
    <div style="border:1px solid #000; padding:10px 10px 10px 20px;">
    <u><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> - posted: <?php the_time('F jS, Y') ?> by: <?php the_author() ?></u><br />
    <div style="margin-left:25px; padding:10px; border 1px solid #eeeeee;">
    COMMENT GOES HERE
    </div>
    </div><br />
    <?php endwhile; ?>
    </ul>

    You can see “COMMENT GOES HERE”, I just need the PHP to call a comment there, and sort it descending, and limit it to one.

    Any thoughts? help? plugins?

  • The topic ‘PHP Code to add single comment to the loop’ is closed to new replies.
Skip to toolbar