2 problems with calling author comments
-
Hi
I’m currently developing a more useful author.php page using the Domtabs javascript to provide three tabbed sections – author bio, latest blogs and latest comments for each author.
I’ve almost go it sorted except for the latest author comments. The code I’m using pulls in all the comments made by the author and displays the entire comment. What I want to do is to just display the comment excerpt and I only want to display the latest 10 comments.
In the code below I’ve tried to call comment_excerpt in place of comment_content but this does not work – do I need to do an additional call in my functions file?
I’ve tried to use a loop on the output of author comments to restrict it to just 10 comments but it did not work. Adding a count to the output is my normal way of restricting output. Is there a way to only pull in the latest 10 comments elsewhere.
I think the problem I’m having is conflicts with the domtab javascript because I don’t see why doing the above does not work.
You can see what I’m trying to do here https://wildlifenews.co.uk/author/kevin/
The code for the author comments I’m using is:
<a name="comments" id="comments">Latest comments</a> <? if(get_query_var('author_name')) : $curauth = get_userdatabylogin(get_query_var('author_name')); else : $curauth = get_userdata(get_query_var('author')); endif; $querystr = " SELECT comment_ID, comment_post_ID, post_title, comment_content FROM $wpdb->comments, $wpdb->posts WHERE user_id = $curauth->ID AND comment_post_id = ID AND comment_approved = 1 ORDER BY comment_ID DESC "; $comments_array = $wpdb->get_results($querystr, OBJECT); if ($comments_array): ?> <ul> <? foreach ($comments_array as $comment): setup_postdata($comment); echo "<li><a href='". get_bloginfo('url') ."/?p=".$comment->comment_post_ID."'>Comment on ". $comment->post_title. "</a><br />". $comment->comment_content . "</li>"; endforeach; ?> </ul> <? endif; ?> </div> </div>
Any help would be appreciated
thanks
Kevin
- The topic ‘2 problems with calling author comments’ is closed to new replies.