Only show comments if > 0 in get_comments for slider, and other modules

Posted in: Newsmag
Post count: 62

Hi,

Feel free to not worry about this one, as I am already doing what I need… but..

I am just wondering if there is probably a better way to do what I am doing.
I want to only show the little number of comments bubble on my home page slider images if there is at least one comment.

What I have done to achieve this is add in a conditional check in the get_comments routine inside td_module_slide.php and td_module.php,td_module_single_base.php (within wp booster) on get_comments_number($this->post->ID) – if it’s above 0, it will add it to $buffy..

Would there be a more clean way to do this?

  • This topic was modified 10 years by jsup.
Post count: 6535

Hi

The best way of doing that is trough a check as you did. Basically there you don’t need anything else then a check if the value is greater then 0.

Thanks!

Post count: 20

would you please paste the altered function get_comments() ?

thanks in advance

Post count: 62

Please tell me which version of the theme you are running. There are slight changes throughout various versions of this theme – I wouldn’t want to give you the wrong code 🙂

Post count: 62

In the versions I have been running with, I just added an extra line and a check – you could probably achieve this more “cleanly”, but here’s my modification (I added in $GCN to store the number of comments, then I tested for it being greater than 0 – fairly straightforward I thought):

**UNFORTUNATELY – This editor stripped some code from the sample. I can’t post the code here 🙁

This would need to be replaced in the following files (from memory – I haven’t looked since June):

~/includes/modules/td_module_slide.php
~/includes/wp_booster/td_module.php
~/includes/wp_booster/td_module_single_base.php

Of course, if you have not set up a child theme, you will lose these changes upon next update.

NOTE: The sample code above is provided as is and there is warranty on its performance or effectiveness. Use this code at your own risk. If you are not sure what you are doing, don’t do it. The code may reference a version of the theme that is different to yours. Always compare the code with your existing code before replacing anything.

  • This reply was modified 9 years by jsup.
Post count: 62

I tried to post the modified code but the editor here stripped some of the code. If you would like the full example, I can post it on a temporary web page for you to retrieve external to here..

Post count: 6535

Hi

You can also use http://pastebin.com/ to share your code here.
Thanks!

Viewing 7 posts - 1 through 7 (of 7 total)
The forum ‘Newsmag’ is closed to new topics and replies.