WordPress most commented posts of last X days
Try removing the filter after your query, so it does not affect other queries around your page. //.. your loop… endwhile; wp_reset_query(); remove_filter( ‘posts_where’, ‘filter_where’ );
Try removing the filter after your query, so it does not affect other queries around your page. //.. your loop… endwhile; wp_reset_query(); remove_filter( ‘posts_where’, ‘filter_where’ );
There is apparently some sort of query call that takes place as part of the comments_template() call, just as there is with loop calls. When I put my custom function in the comments template, it works perfectly. I tried putting the entire contents of the comments template into my custom loop-single template, and it didn’t … Read more
Try this: <?php comment_form(); ?> References: Function Reference for comment_form(); on WordPress Codex comment_form(); WordPress function reference, arguments and source at QueryPosts
your query doesn’t restrict posts without comments. $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts( ‘cat=-8378, -13444&orderby=comment_count&paged=’ . $paged ); while (have_posts()) : if( get_comments_number() ) the_post(); […] reference: get_comments_number()
Just open the comments.php file from your theme. Find the following line (or similar) <?php foreach ($comments as $comment) : ?> Add this lines just above it if (isset($_GET[‘comOrder’]) && $_GET[‘comOrder’] == ‘Newest’ ) $comments = array_reverse($comments, true); so your code looks like this: <?php if (isset($_GET[‘comOrder’]) && $_GET[‘comOrder’] == ‘Newest’ ) $comments = array_reverse($comments, … Read more
I’m using the “comments_template()” function with no additional parameters, which loads the default “comments.php” from the wp-includes library. That’s your problem. The compat version is unmaintained and obsolete. Theme-compat files are officially no longer supported, as of WordPress 3.0. (See here.) You need to define and include comments.php in your Theme.
On the bottom of comments.php I use the following code: <?php comment_form(array(‘comment_field’ => ‘<p class=”comment-form-comment”><label for=”comment”>Comment</label><textarea id=”comment” name=”comment” cols=”45″ rows=”8″ aria-required=”true”></textarea></p>’, ‘comment_notes_before’ => ‘<p class=”comment-notes”>Your email address will not be published. Required fields are marked *</p>’, ‘comment_notes_after’ => ”, ‘title_reply’ => ‘Leave a Reply’, ‘title_reply_to’ => ‘Leave a Reply to %s’, ‘label_submit’ => ‘Post comment’, … Read more
You could use get_comments() instead. The code in this forum post gives an example of how you’d do that: <?php $recent_comments = get_comments( array(‘post_id’ => $newest_post_id,) ); foreach ($recent_comments as $comment) { ?> <?php $comment_id = get_comment($comment->comment_ID); $author = $comment_id->comment_author; $commentdate = $comment_id->comment_date; $content = $comment_id->comment_content; ?> <p><?php echo $author; echo $commentdate;?></p> <p><?php echo $content;?></p> … Read more
the function you posted is limited to 5 comments which means it should work, but anyway there is no need for a custom SQL query when you can use the native get_comments function function showLatestComments() { $comments = get_comments(array( ‘status’ => ‘approve’, ‘number’ => ‘5’ ) ); $output .= ‘<h2>Latest student perspectives <img src=”https://wordpress.stackexchange.com/wp-content/themes/blue-and-grey/images/hmepage-tri.png” class=”class3″ … Read more
You can use wp_insert_comment action, which is triggered on every comment insertion.