Re: How to add a view counter to forums-loop??
@jillian, found the little snippet in the plugin from bbpress and attempted to implement it for you, experimenting myself: @r-a-y, help me on any corrections:
`// update meta
$value = get_site_option($bp->current_component”_topic_views_”.$topic);
add_site_option($bp->current_component”_topic_views_”.$topic, $value+1);`
Than the function added:
`function bp_the_topic_view_count($topic_id = false, $echo = true) {
global $action_variables;
global $bp;
global $forum_template;
if($topic_id == false)
$views = get_site_option($bp->current_component”_topic_views_”.$forum_template->topic->topic_id);
else
$views = get_site_option($bp->current_component”_topic_views_”.$topic_id);
if(!$views)
return false;
if($echo)
{
if($views == 1)
echo apply_filters( ‘bp_the_topic_post_count’, $views.” view” );
else
echo apply_filters( ‘bp_the_topic_post_count’, $views.” views” );
}else
{
if($views == 1)
return apply_filters( ‘bp_the_topic_post_count’, $views.” view” );
else
return apply_filters( ‘bp_the_topic_post_count’, $views.” views” );
}
`
Not tested.