Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Blue_Dragon360 on "How can I detect whether a comment is a reply and nest it?"

$
0
0

I've decided to integrate wordpress into the site I'm building, and am currently working on the main page (on a localhost, so I can't share the link). I've set withcomments=0 and added a comments loop to display 3 comments under each post on the home page. This works well, but I'm having a problem: Comment replies aren't nested. Is there a function or something I can use to make this happen?

Also, I'm having trouble getting the reply and edit links to work. When I use comment_reply_link and edit_comment_link nothing displays. What do I need to do?

Here's my comments loop:

<?php
				//defines $args variables
				$args = array(
					'number' => '3',
					'post_id' => get_the_ID(),
				);
				//starts the comment loop
				$comments = get_comments($args);
				foreach($comments as $comment) :
					//echos the HTML layout
					echo("<div class='commentContainer'><div class='avatarContainer'><div class='commentAvatar'>".
						//gets the avatar
						get_avatar($comment,90).
						//gets the author
						"</div><div class='commentAuthor'>".
							$comment->comment_author.
								"</div>");
						//checks to see if the author is the main post author
					if ( $post = get_post($post_id) ) {
					            if ( $comment->user_id === $post->post_author ){
									//echos a special "author tag" under the avatar of the author's post
					            	echo ("<div class = 'commentPostAuthor'>Post Author</div>");
					            }

					        }
									//gets the comment content
									echo ("</div><div class='commentContent'>".
									$comment->comment_content.
										//echos the comment action bar, a bar that comes up when hovering on the comment that contains the edit, reply, and permalink links
										"<div class='commentActions'> ");
									echo "<div class = 'editLink'>";
									//edit link (brokem)
									edit_comment_link('Edit');
									//reply link (broken)
									echo "</div><div class = 'replyLink'>";
									comment_reply_link();
									//<div class = "commentPermalink" (placeholder)
									echo "</div>";

									echo("</div>".
										"</div></div>" );
				//ends the loop
				endforeach;
				?>

Here's my full loop on Pastebin:
http://pastebin.com/R2n9bFN1

EDIT: Did someone move this to the hacks section? If not I think I'm going crazy, I could've sworn I put it in how to and troubleshooting :P


Viewing all articles
Browse latest Browse all 8245

Trending Articles