The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Hottest Comment Thr...
 
Share:
Notifications
Clear all

Question [Solved] Hottest Comment Threads Filter Button

15 Posts
2 Users
3 Reactions
524 Views
Posts: 32
Topic starter
(@doctorbr)
Trusted Member
Joined: 11 months ago

The first image shows that the Hottest Comment Threads Filter Button appears even when there is no comments!

2024 07 04 22 47 29

The second image shows the Comments Sorting Buttons as well as the Hottest Comment Threads Filter Button as it has to be, as there are 16 comments.

2024 07 04 22 45 51

Is it possible to use a snippet code to correct the problem or is it necessary to update the wpDiscuz plugin?

If so, what would be the code?

Thanks in advance!

Website URL
14 Replies
Asti
Posts: 7615
 Asti
Support
(@asti)
Illustrious Member
Joined: 7 years ago

Hi,

We'll check and get back to you soon. 

Reply
Posts: 32
Topic starter
(@doctorbr)
Trusted Member
Joined: 11 months ago

Hello,

Any news about this?

Thanks in advance!

 

 

Reply
1 Reply
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7615

@doctorbr 

You can use the code below to control the display of the filters and sorting buttons:

const commentsCount = parseInt(jQuery('.wpd-thread-info').attr('data-comments-count'), 10);
if (isNaN(commentsCount) || (typeof commentsCount === 'undefined') || commentsCount < 1) {
    jQuery('.wpdf-hottest').hide();
}
Hello world! – wpDiscuz — Mozilla Firefox

 

Reply
Posts: 32
Topic starter
(@doctorbr)
Trusted Member
Joined: 11 months ago

@Asti

I can't activate the PHP code. See the error:

We encountered an error activating your snippet, please check the syntax and try again. Error message: syntax error, unexpected identifier commentsCount 

 

 

 

Reply
1 Reply
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7615

@doctorbr 

This is a javascript code, not the PHP. 

Reply
Posts: 32
Topic starter
(@doctorbr)
Trusted Member
Joined: 11 months ago

@Asti

Still does not work.

 

2024 07 11 16 13 13

What can be wrong?

Reply
1 Reply
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7615

@doctorbr 

Try this one:

jQuery(document).ready(function() {
    const commentsCount = parseInt(jQuery('.wpd-thread-info').attr('data-comments-count'), 10);
    if (isNaN(commentsCount) || (typeof commentsCount === 'undefined') || commentsCount < 1) {
          jQuery('.wpdf-hottest').hide();
     }
});
Reply
Posts: 32
Topic starter
(@doctorbr)
Trusted Member
Joined: 11 months ago

@Asti

It worked, but Lighthouse accused errors!

 

2024 07 12 21 44 36

What can be done to avoid these errors?

PS. I used your code to create another to hide the comments sorting buttons too...

 

jQuery(document).ready(function() {
const commentsCount = parseInt(jQuery('.wpd-thread-info').attr('data-comments-count'), 10);
if (isNaN(commentsCount) || (typeof commentsCount === 'undefined') || commentsCount < 2) {
    jQuery('.wpdf-sorting').hide();
}
});

 

Thanks in advance!

Reply
Posts: 32
Topic starter
(@doctorbr)
Trusted Member
Joined: 11 months ago

@Asti

I disabled the additional snippet I mentioned and limited your snippet exclusively for posts (location: site wide header).

Errors no longer appear in Lighthouse and I hope I have done nothing that harms my site or the wpDiscuz plugin. 🤔 

2024 07 12 22 59 51

 

But I would still like to hide the comments sorting buttons too!

Please, could you change your code so that the comments sorting buttons are also hidden when there is only 1 comment?

In my opinion it makes no sense to show filters when there is 1 comment. Filters cannot do anything with only 1 comment. 🙂 

Thanks in advance!

 

Reply
Page 1 / 2
Share: