Support Forum

Blog Post Linking – getting my theme to acknowledge comments made via forum

JG Jasneet Gulati
Jasneet Gulati
Member

Hi guys,

I’ve had a search and couldn’t find the solution to this.

This is my first post, and I’d just like to say that I am really enjoying the ease of using Simple:Press and that it’s a great forum. Thank you for your hard work.

I have used the blog linking to great success – it works!

The only thing that is not perfect is that only the comments I make on the front end of my blog get recorded such that it will display ‘5 comments’ – even though there there may be a total of 15 comments to read (10 comments made on the forum).

How can I change this so that the comments counter acknowledges the posts made on the forum as a comment, too.

To rephrase if I am not making myself clear is that although the linking itself is working perfectly, the ‘number of comments’ is not accurate as it does not count the comments from the forum.

I realise that the solution needs to correct the counting of comments within the singlepost.php and also on the front end of my blog ie. ‘recent posts’ as they are all inaccurate.

I hope this makes sense, if not I will be happy to clarify.

I have no knowledge of php – so if you would like I could copy and paste any code from my theme at your request in order to diagnose and correct the issue.

Kindest regards.

JG

20 Answers

New Answer

MP Mr Papa
Mr Papa
Member

may need Andy to weigh in here since he wrote the blog linking plugin, but lets give it a shot…

so you are successfully getting comments synced between the blog post and the forum topic?  just the count is not correct on the blog post?

can you look in the theme comments.php file (assuming it has one) and see how it is accessing the comments? if its relatively recent theme, its likely accessing it via

wp_list_comments()

with some arguments…  I would like to know what those arguments are…

JG Jasneet Gulati
Jasneet Gulati
Member

Hi Mr. Papa thank you kindly for your swift reply.

Mr Papa said 
so you are successfully getting comments synced between the blog post and the forum topic?  just the count is not correct on the blog post?

Yes you are absolutely correct.

Later today, when I get a chance, I will copy and paste the comments.php. From memory, I can confirm that it did have the ‘wp_list_comments()’.

Thank you kindly, I will be back later today!

JG

YS Yellow Swordfish
Yellow Swordfish
Member

Actually we can probably do a little better than this.

The most common WP function for displaying the number of comments is a function called comments_number().

Take a look through the comments php file to see if you can find this function being used. If it is – comment it out and replace it with the following:

spCommentsNumber("0 Comments", "1 Comment", "% Comments", true);

Replacing those labels with your preferred text of course.

JG Jasneet Gulati
Jasneet Gulati
Member

YellowSwordfish,

That has worked perfectly, thank you.

This is the result:

It has worked It now displays the correct number of comments at the bottom.

I also used your code to edit the following in single.php – and it too worked. The image below shows before I used your code.

I changed ‘comments_popup_link(‘0′,’1′,’%’);’ in single.php to what you have suggested, and that has worked perfectly!

 However, I couldn’t find an obvious place to insert your code for it to work with the recent posts widget (see pic). This is what it displays on my home page – showing 5 comments, not 11. Any ideas, sir?

I suspect I have to change something with the widget?

Thank you for your help!

YS Yellow Swordfish
Yellow Swordfish
Member

That one is going to be much trickier and might depend on how it is wrotten.
What widget is this? Is this the stadard Wp supplied widget or a special one supplied with theme or another plugin?

JG Jasneet Gulati
Jasneet Gulati
Member

Thanks Yellow Swordfish.

This particular widget is one supplied by the Theme – the theme is called Avenue.

Would this work if I used a standard wordpress widget, you think?

YS Yellow Swordfish
Yellow Swordfish
Member

As I say it depends on the code and I canlt vouch for either of them. Can you send me the widget code by any chance?

JG Jasneet Gulati
Jasneet Gulati
Member

I could send you the entire widget code at your request but there’s quite a lot in there.

Searching for the term ‘comment’ this is what comes up:

<h2><a href='<?php the_permalink(); ?>’ title='<?php the_title(); ?>’><?php the_title(); ?></a></problem-with-post-edit-button2>

<span class="block-meta"><?php the_time(‘F j, Y’); ?>, <?php comments_popup_link(); ?></span>

</div>

<?php endif; ?>

<?php $counter++; endwhile; ?>

YS Yellow Swordfish
Yellow Swordfish
Member

Well there is that comments_popup_link() function again that you changed last time so it might be worth trying it in this code as well perhaps? Never any harm in trying!

JG Jasneet Gulati
Jasneet Gulati
Member

You’re too right – never harm in trying.

I changed it to this:

<span class="block-meta"><?php the_time('F j, Y'); ?>, <?php spCommentsNumber("0 Comments", "1 Comment", "% Comments", true); ?></span>

But what it seems to have done is update ALL my posts as having 11 comments on them – even those that have no comments, 1 comment or whatever number.

Here’s a picture to explain what happened:

How can I make that comment number specific to that particular post?

YS Yellow Swordfish
Yellow Swordfish
Member

Could you try making one small change to where you call the SP function? See if it helps.

This just adds one extra parameter at the end of the call…

spCommentsNumber("0 Comments", "1 Comment", "% Comments", true, the_ID());

I am hoping that might fix the issue.

JG Jasneet Gulati
Jasneet Gulati
Member

Hey mate,

Thanks for your reply.

I have made the change, and the effect it has had is that it now displays an absurd number. e.g. 53912 comments, 14812 comments etc

What I have noticed is that they all end in ’12’ (which was the number of comments on the one article I have blog linked thus far).

Perhaps the first 3 digits are the ID number of the post?

YS Yellow Swordfish
Yellow Swordfish
Member

Oh stupid, stupid me!

That parameter should be:

get_the_ID()

NOT

the_ID()

Sorry – try that instead.

JG Jasneet Gulati
Jasneet Gulati
Member

Don’t be so hard on yourself!

Your new solution has worked.

THANK YOU ONCE AGAIN!

Brilliant!