Support Forum

Comment Count on Linked Blog Posts

JO JohnD
JohnD
Member

I’ve recently added the linked blog post option to my site and am noticing one issue with the installation and am unsure of how to fix it. 

Both comments left on the blog post and replies left within the forum will pass to their respective places – That is to say that a comment left on the blog shows up in the forum and vice versa. However, only comments left on the blog post add to the comment count of the post. 

You can see this on my test post on my site here which has 4 comments two created on the post and 2 created using the forum. WordPress only sees the two that were created using the comment box under the post while the other two are displayed but not counted as comments.

http://www.phogropathy.com/what-exactly-is-iphoneography-anyway/

However the same post on the forum has all four comments and they are counted properly. 

http://www.phogropathy.com/forum/general-discussion/what-exactly-is-iphoneography-anyway/

So long story short, is there a way to display the comments as they are displayed within this post on my site, but have wordpress count the total of both WP comments and Forum comments in the comment count on the blog post?

17 Answers

New Answer

MP Mr Papa
Mr Papa
Member

have you replaced the wp comment count template tag with ours?  that would be:  spCommentsNumberTag()

WP recently just updated their comments count to add a new filter to it… so it will now be possible for us to adjust the count without using our template function…  we just need to find the time to update our plugin to use the new wp filter… soon hopefully…

JO JohnD
JohnD
Member

Mr Papa said
have you replaced the wp comment count template tag with ours?  that would be:  spCommentsNumberTag()

WP recently just updated their comments count to add a new filter to it… so it will now be possible for us to adjust the count without using our template function…  we just need to find the time to update our plugin to use the new wp filter… soon hopefully…

I’m not exactly sure how to change this, it might not be possible with the theme I’m using (headway 3.0). Or maybe I’m looking in the wrong place?

MP Mr Papa
Mr Papa
Member

typically it would be in the comments.php file in your theme… do you have one of those?  if its a recent theme, look for

get_comments_number()

we can help change it up… 

JO JohnD
JohnD
Member

Yeah, it seems that Headway doesn’t have a comments.php file that I can access. Not really sure if there’s a way I can do this using their theme so I might have to just wait for the update to the plugin.

I have opened a topic over on their support forum as well to see if they have any insight into how I’d go about changing this bit of code I’ll follow up here if they have a solution incase anyone else ends up with the same issue.

Thanks for the speedy replies :)

MP Mr Papa
Mr Papa
Member

not familiar with headaway – using it that is, have heard of it… ;)

and themes have many, many ways to output comments count…  could be single.php or other… and themes can do their own thing too…

maybe we can try something real quick…  in the spFunctions.php file of the theme you are using (in the template files dir), try adding this code into it at the bottom, but inside the closing }

add_filter('get_comments_number', 'my_comments_count', 10, 2);  
function my_comments_count($count, $postid) {
    $total = 0;
    $links = sp_blog_links_control('read', $postid);
    if ($links) sp_forum_api_support();
    if ($links && sp_get_auth('view_forum', $links->forum_id)) {
        $sfpostlinking = sp_get_option('sfpostlinking');

        # link found for this post
        $total = sp_get_posts_count_in_linked_topic($links->topic_id, $sfpostlinking['sfhideduplicate']) - 1;
    }
    $count = $count + $total;
    return $count;
}

and lets see if that does anything…

JO JohnD
JohnD
Member

Thanks for the try, but adding this code doesn’t seem to have any effect on what is counted as comments on the blog post. 

MP Mr Papa
Mr Papa
Member

okay, will have to dig deeper…  that was a try at using the new wp filter on the comment count and adding in our comment count…

headway may be doing it non standard..

lets make sure its getting called at least…  right after the function definition (before $total = 0), add

vshow(‘here’);

and see if that shows up in the display…

JO JohnD
JohnD
Member

I’m not sure if this is related, but I just noticed that the comments which are passed to the linked post from the forum don’t show up as comments in my WP dashboard even though they are displayed within the post on the blog.

JO JohnD
JohnD
Member

Mr Papa said
okay, will have to dig deeper…  that was a try at using the new wp filter on the comment count and adding in our comment count…

headway may be doing it non standard..

lets make sure its getting called at least…  right after the function definition (before $total = 0), add

vshow(‘here’);

and see if that shows up in the display…

This again doesn’t seem to do anything. Although I’m not sure what you mean by “shows up in the display”. 

MP Mr Papa
Mr Papa
Member

No, they wont get added to the wp admin…

It should print out ‘Here’ on the page where the comments come out…

That indicates to me, that Headway is not grabbing comments using the WP API…  which will make it very hard for us to affect…   or that the code I gave you was not entered correctly…

can you post the spFunctions.php changes you made?  include some code above and below where you entered my code…  please use the code button to format it properly…

you could also try putting the code in your wp theme functions.php file too vs our spFunctions.php file…

JO JohnD
JohnD
Member

Here’s what I currently have for code

Also, when I add the code you gave me to the WP functions.php I receive this error Parse error: syntax error, unexpected ‘}’ in /problem-with-post-edit-buttonome2/phogropa/public_html/wp-content/themes/problem-with-post-edit-buttoneadway/functions.php on line 37

function spDefault_spShowFontResize() {

$tipMinus = __sp(‘decrease forum font size’);

$tipReset = __sp(‘reset forum font size’);

$tipPlus = __sp(‘increase font size’);

sp_FontResizer(‘tagClass=spFontSizeControl spRight’, $tipMinus, $tipReset, $tipPlus);

sp_InsertBreak(‘direction-right’);

add_filter(‘get_comments_number’, ‘my_comments_count’, 10, 2);

function my_comments_count($count, $postid) {

vshow(‘here’);

$total = 0;

$links = sp_blog_links_control(‘read’, $postid);

if ($links) sp_forum_api_support();

if ($links && sp_get_auth(‘view_forum’, $links->forum_id)) {

$sfpostlinking = sp_get_option(‘sfpostlinking’);

# link found for this post

$total = sp_get_posts_count_in_linked_topic($links->topic_id, $sfpostlinking[‘sfhideduplicate’]) – 1;

}

$count = $count + $total;

return $count;

}

}

?>

JO JohnD
JohnD
Member

Actually – the error that your code creates is – 

Fatal error: Call to undefined function sp_get_posts_count_in_linked_topic() in /problem-with-post-edit-buttonome2/phogropa/public_html/wp-content/themes/problem-with-post-edit-buttoneadway/functions.php on line 30.

That previous error was something I’d created and didn’t even realize I’d copied it incorrectly. 

MP Mr Papa
Mr Papa
Member

sorry, watching NFL…

so inside the function, at the top, add:

    include_once(SPBLLIB.’sp-linking-blog.php’);

JO JohnD
JohnD
Member

Oh no worries I’ve got the game on as well – it’s good to be back to football season!

And adding this code to the WP function file did the trick!

Thanks so much for your help much appreciated!