User Comments – Display not working
-
Hi All,
I am trying to display user comments on there profile page. I have take over from another developer that is not very helpful and has left me in a bit of a mess. I think I have worked out where the issue is but this is the code chunk I have.
I think the issue is inside the UL as now I have made comments to test I am getting a blank area. When I check with FireBug I see the UL tags but nothing inside. There should be 2. I don’t see any li tags or anything just the UL so I am guessing its not calling the comments correctly.
Please help.
<div class=”commentsReviews comm”>
<h1>Comments</h1>
<?php // Posts per page setting
$ppp = 1000; // either use the WordPress global Posts per page setting or set a custom one like $ppp = 10;
$custom_offset = 0; // If you are dealing with your custom pagination, then you can calculate the value of this offset using a formula// category (can be a parent category)
$category_parent = 0;// lets fetch sub categories of this category and build an array
$categories = get_terms( ‘category’, array( ‘child_of’ => $category_parent, ‘hide_empty’ => false ) );
$category_list = array( $category_parent );
foreach( $categories as $term ) {
if($term->term_id != 29) $category_list[] = (int) $term->term_id;
}// fetch posts in all those categories
$posts = get_objects_in_term( $category_list, ‘category’ );$sql = “SELECT comment_ID, comment_date, comment_content, comment_post_ID, comment_author
FROM {$wpdb->comments} WHERE
comment_post_ID in (“.implode(‘,’, $posts).”) AND comment_approved = 1
ORDER by comment_date DESC LIMIT $ppp OFFSET $custom_offset”;$comments_list = $wpdb->get_results( $sql );
if ( count( $comments_list ) > 0 ) {
$date_format = get_option( ‘date_format’ );
echo ‘- ‘;
foreach ( $comments_list as $comment ) {
$commentUser = get_userdatabylogin( $comment->comment_author );
if ( $commentUser->user_login == $authorName ) {
echo ‘<li class=”profileComments”>Comment: ‘.substr( $comment->comment_content, 0, 500 ).’..
Date: ‘. $author . ‘ ‘ .date( $date_format, strtotime( $comment->comment_date ) ).’
Post: comment_post_ID ).'”>’.get_the_title( $comment->comment_post_ID ).’‘;
}
}
echo ‘‘;
} else {
echo ‘<p>No comments</p>’;
}
?>
</div>
- The topic ‘User Comments – Display not working’ is closed to new replies.