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!


Edited by PauloCot
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.