PauloCot Posted August 2, 2013 Share Posted August 2, 2013 (edited) 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 August 2, 2013 by PauloCot Quote Link to comment https://forums.phpfreaks.com/topic/280754-wordpress-php-object-if-more-than-x-comments-or-if-an-other-object-is-enabled/ Share on other sites More sharing options...
lemmin Posted August 2, 2013 Share Posted August 2, 2013 Assuming this is for WordPress, you probably want to use the wp_count_comments() function: http://codex.wordpress.org/Function_Reference/wp_count_comments More info can be found here: http://codex.wordpress.org/Function_Reference#Comment.2C_Ping.2C_and_Trackback_Functions Quote Link to comment https://forums.phpfreaks.com/topic/280754-wordpress-php-object-if-more-than-x-comments-or-if-an-other-object-is-enabled/#findComment-1443182 Share on other sites More sharing options...
PauloCot Posted August 2, 2013 Author Share Posted August 2, 2013 Yes it is for wordpress. What code would be used though? I'm very new to php. Quote Link to comment https://forums.phpfreaks.com/topic/280754-wordpress-php-object-if-more-than-x-comments-or-if-an-other-object-is-enabled/#findComment-1443268 Share on other sites More sharing options...
lemmin Posted August 2, 2013 Share Posted August 2, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/280754-wordpress-php-object-if-more-than-x-comments-or-if-an-other-object-is-enabled/#findComment-1443284 Share on other sites More sharing options...
trq Posted August 3, 2013 Share Posted August 3, 2013 Nothing in your code and very little within Wordpress are PHP objects. Just saying. Quote Link to comment https://forums.phpfreaks.com/topic/280754-wordpress-php-object-if-more-than-x-comments-or-if-an-other-object-is-enabled/#findComment-1443307 Share on other sites More sharing options...
haley01 Posted August 6, 2013 Share Posted August 6, 2013 Hey.....I am fresher in PHP. If possible for you could you please share some more information on this topic. Quote Link to comment https://forums.phpfreaks.com/topic/280754-wordpress-php-object-if-more-than-x-comments-or-if-an-other-object-is-enabled/#findComment-1443674 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.