Office Address

41/D, West Brahmondi, Narsingdi

Phone Number

+880-1975374887

Email Address

[email protected]

This short code will show the current topic info of the bbpress forum plugin on the sidebar. You can place this code on your theme functions.php file.

 

[php] /**
* bbpress topic info short code
*/
function bbpress_topic_info_func( $atts ){

global $wp_query;
$post = $wp_query->get_queried_object();

if($post->post_type == "topic"){

ob_start();

?>

<ul class="topic-info">
<li class="topic-forum">
In:<?php echo get_the_title($post->post_parent);?>
</li>
<li class="reply-count">
<?php echo bbp_get_topic_post_count($post->ID, false);?> Replies
</li>
<li class="voice-count">
<?php echo bbp_get_topic_voice_count($post->ID, false); ?> Participants
</li>
<li class="topic-freshness-author">
Last Activity <?php echo bbp_get_topic_last_active_time($post->ID, false); ?>
</li>
<li class="topic-subscription-link"><?php bbp_topic_subscription_link(); ?></li>
<li class="topic-favorites-link"><?php bbp_user_favorites_link(); ?></li>
</ul>

<?php
return ob_get_clean();

}

}
add_shortcode( ‘bbpress-topic-info’, ‘bbpress_topic_info_func’ );

/**
* bbpress subscription link | hide
* From https://bbpress.org/forums/topic/is-there-a-way-to-remove-this-character-next-to-the-subscription-link/
*/

function hide_before ($args = array() ) {
$args[‘before’] = ”;
return $args;
}
add_filter (‘bbp_before_get_forum_subscribe_link_parse_args’,’hide_before’) ;
[/php]

You can use this short code like this [bbpress-topic-info]

 

Written by

Maidul Islam

I am a freelance web developer.Like to share what i learn.