Quantcast
Channel: bbPress.org » All Posts
Viewing all articles
Browse latest Browse all 3646

Reply To: how can i show latest thred

$
0
0

ok, so drop the following into your functions file

//  Display just latest topic
function display_latest_topic() {  

	$topics_query = array(
					'post_type'           => bbp_get_topic_post_type(),
					'post_parent'         => $settings['parent_forum'],
					'posts_per_page'      => '1',
					'post_status'         => array( bbp_get_public_status_id(), bbp_get_closed_status_id() ),
					'ignore_sticky_posts' => true,
					'no_found_rows'       => true,
					'order'               => 'DESC'
				);
				
	$lt_query = new WP_Query( $topics_query );
		
	while ( $lt_query->have_posts() ) {
			
		$lt_query->the_post();
			$topic_id    = bbp_get_topic_id( $lt_query->post->ID );
?>
<h2> Latest topic </h2>
<h3> <a href="<?php bbp_reply_url(); ?>" class="bbp-reply-permalink"><?php bbp_topic_title($topic_id); ?></a></h3>
		
<div id="bbpress-forums">
		
		<div id="post-<?php bbp_reply_id(); ?>" class="bbp-reply-header">

	<div class="bbp-meta">

		<span class="bbp-reply-post-date"><?php bbp_reply_post_date(); ?></span>

		<a href="<?php bbp_reply_url(); ?>" class="bbp-reply-permalink">#<?php bbp_reply_id($topic_id); ?></a>
		
	</div><!-- .bbp-meta -->

</div><!-- #post-<?php bbp_reply_id(); ?> -->

<div <?php bbp_reply_class(); ?>>

	<div class="bbp-reply-author">

		<?php bbp_reply_author_link( array( 'post_id' => $topic_id, 'sep' => '<br />', 'show_role' => true ) ); ?>

		</div><!-- .bbp-reply-author -->

	<div class="bbp-reply-content">

		<?php bbp_reply_content(); ?>

	</div><!-- .bbp-reply-content -->

</div><!-- .reply -->
</div><!--div bbpress-forums--->

	<?php
		
	} }

and then on your page template add this function where you want it. I’ve wrapped it in an if is_front_page statement so it only shows on the frontpage. You night need to use is_home instead depending on how your blog is set up.

If you want it in the body, you should put it within the content div, either before or after the loop depending if you want it at the of or bottom of the page. You may need to play a bit !


Viewing all articles
Browse latest Browse all 3646

Trending Articles