Jump to content

[WordPress] PHP object if more than x comments or if an other object is enabled


PauloCot

Recommended Posts

I have two PHP objects



if(function_exists('wp_commentnavi')) { wp_commentnavi(); }

which is the comment pagination and



if(function_exists('wp_commentnavi_all_comments_link')) { wp_commentnavi_all_comments_link(); }

which is the all comments link.


 


I would like the second, all the comments link, to be only displayed if


 


a) there are more than x comments OR


 


b) if the comment pagination isn't displayed neither should the all comments link.


 


Essentially I want to say display all comments link if there are more than x comments, if not don't display all comments link.


Anyone know the code required to do this?


Thanks in advance!


You'll have to do some research then. The wp_count_comments() function accepts a post ID, so I would look around that code area for a variable that might contain that. Once you have that, you can add your logic:

$comments_num = wp_count_comments($post_id);
if ($comments_num > 5)
    //show more code

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.