Skip to:

PHP check – show latest replies only

  • Shmoo


    Just curious as I’m not a PHP-er and learning each day.

    What I’m trying to make is a front-end tab-system that shows three tabs
    Tab [1] = Topics
    Tab [2] = Replies
    Tab [3] = Refresh, just a reload of the page

    bbPress list latests - Topics and Replies

    This should be a very easy query-/loop in general, it’s just a list of all new topics that have been added to my forum. There’s only one little thing, it should order at the date of creation so that when an older topic gets a reply it doesn’t bounce to the top of the list.

    This should be a query for latests updated topics of any age, if a topic of 5 years old receives an update or bounce it should jump to the top of this list. + newly or older created topics without replies shouldn’t get listed inside this second ‘Replies’ tab.

    I came up with this idea:

    <?php if ( bbp_has_topics( array( 'show_stickies' => false, 'order' => 'DESC', 'posts_per_page' => 120, 'max_num_pages' => 1 ) ) ): ?>
    <?php while ( bbp_topics() ) : bbp_the_topic(); ?>
    	<?php if ( bbp_get_topic_reply_count() ) {
    	 bbp_get_template_part( 'last-topic-activity/last-replies-loop' );
    	} ?>
    <?php endwhile; ?>
    <?php endif; ?>

    posts_per_page => 120 is a little bold but it’s just for testing right now.
    Just curious if this is okay to work with, I found the bbp_get_topic_reply_count() function and it has a True or False statement so I thought lets just check if the topics have a reply_count … if it’s true than list a bunch of stuff through the custom-loop template I made.

    Hope somebody can verify if this is okay, it looks like it’s working.

  • You must be logged in to reply to this topic.
Skip to toolbar