I am using comment_form() in Wordpress, and the comment form is showing up, but the actual comments that have been approved are not:
Here is the code I have
<?php
$comments_args = array(
// remove "Text or HTML to be displayed after the set of comment fields"
'comment_notes_after' => 'Note: Comments are moderated so will not publish immediately.',
// change "Leave a Reply" to "Comment"
'title_reply'=>'What did you think of this story? Please share a comment.',
// change the post comment button
'label_submit' => __( 'Submit your comment' ),
);
comment_form($comments_args);
?>
I have unchecked and checked the right options under Settings -> Discussion
Do I need another call apart from comment_form?
Does it make a difference that this is a custom post type?
Thanks for any help.
Try to use the comments.php file from the twentyfourteen theme. If it works, it is likely that nishant is right with comments probably not being activated for your post type.
TwentyFourteen’s comments.php is also a good example on best practise for comments. You might check it against your other code, if there is some.
It doesn't make any difference if it is a custom post type but you should declare comment support for your custom post type in function.php where you have written arguments for custom post type. e.g. 'supports' => array( 'title' ,'author','comments').
And Use like this in single-post-type.php write <?php comments_template( '', true ); ?> to call comments.php.
And in take your comments.php as backup and replace it with the following -
<?php
/**
* The template for displaying Comments
*
* The area of the page that contains both current comments
* and the comment form. The actual display of comments is
* handled by a callback to twentytwelve_comment() which is
* located in the functions.php file.
*
* #package WordPress
* #subpackage Twenty_Twelve
* #since Twenty Twelve 1.0
*/
/*
* If the current post is protected by a password and
* the visitor has not yet entered the password we will
* return early without loading the comments.
*/
if ( post_password_required() )
return;
?>
<div id="comments" class="comments-area">
<?php // You can start editing here -- including this comment! ?>
<?php if ( have_comments() ) : ?>
<h2 class="comments-title">
<?php
printf( _n( 'One thought on “%2$s”', '%1$s thoughts on “%2$s”', get_comments_number(), 'twentytwelve' ),
number_format_i18n( get_comments_number() ), '<span>' . get_the_title() . '</span>' );
?>
</h2>
<ol class="commentlist">
<?php wp_list_comments( array( 'callback' => 'twentytwelve_comment', 'style' => 'ol' ) ); ?>
</ol><!-- .commentlist -->
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
<nav id="comment-nav-below" class="navigation" role="navigation">
<h1 class="assistive-text section-heading"><?php _e( 'Comment navigation', 'twentytwelve' ); ?></h1>
<div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 'twentytwelve' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 'twentytwelve' ) ); ?></div>
</nav>
<?php endif; // check for comment navigation ?>
<?php
/* If there are no comments and comments are closed, let's leave a note.
* But we only want the note on posts and pages that had comments in the first place.
*/
if ( ! comments_open() && get_comments_number() ) : ?>
<p class="nocomments"><?php _e( 'Comments are closed.' , 'twentytwelve' ); ?></p>
<?php endif; ?>
<?php endif; // have_comments() ?>
<?php //comment_form(); ?>
<?php if ('open' == $post->comment_status) : ?>
<div id="respond" class="comment-respond">
<h3 id="reply-title" class="comment-reply-title"><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3>
<div id="cancel-comment-reply">
<p class="small"><?php cancel_comment_reply_link( __("Cancel Reply", "bonestheme") ); ?></p>
</div>
<div class="cancel-comment-reply">
<?php cancel_comment_reply_link(); ?>
</div>
<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
<p>You must be logged in to post a comment.</p>
<?php else : ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if ( $user_ID ) : ?>
<p>Logged in as <?php echo $user_identity; ?>. Log out »</p>
<?php else : ?>
<p class="comment-notes">Your email address will not be published. Required fields are marked <span class="required">*</span></p>
<p class="comment-form-author"><label for="author">Name <?php if ($req) echo '<span class="required">*</span>'; ?></label>
<input type="text" name="author" id="author" value="<?php //echo $comment_author; ?>" size="22" tabindex="1" /></p>
<p class="comment-form-email"><label for="email">Mail <?php if ($req) echo '<span class="required">*</span>'; ?></label>
<input type="text" name="email" id="email" value="<?php //echo $comment_author_email; ?>" size="22" tabindex="2" /></p>
<p class="comment-form-url"><label for="url">Website</label>
<input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" /></p>
<?php endif; ?>
<!--<p class="form-allowed-tags"><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>-->
<p class="comment-form-comment"><p><label for="comment">Comment <?php if ($req) echo '<span class="required">*</span>'; ?></label>
<textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
<p class="form-submit"><input name="submit" type="submit" id="submit" tabindex="5" value="Post Comment" />
<?php comment_id_fields(); ?>
</p>
<?php do_action('comment_form', $post->ID); ?>
</form>
<?php endif; // If registration required and not logged in ?>
</div>
<?php endif; // if you delete this the sky will fall on your head ?>
</div><!-- #comments .comments-area -->
Note- Please change class name and id as per your css
Related
Have this code in: woocommerce/templates/myaccount/view-order.php
defined( 'ABSPATH' ) || exit;
$notes = $order->get_customer_order_notes();
?>
<p>
<?php if ( $notes ) : ?>
<h2><?php esc_html_e( 'Order updates', 'woocommerce' ); ?></h2>
<ol class="woocommerce-OrderUpdates commentlist notes">
<?php foreach ( $notes as $note ) : ?>
<li class="woocommerce-OrderUpdate comment note">
<div class="woocommerce-OrderUpdate-inner comment_container">
<div class="woocommerce-OrderUpdate-text comment-text">
<p class="woocommerce-OrderUpdate-meta meta"><?php echo date_i18n( esc_html__( 'l jS \o\f F Y, h:ia', 'woocommerce' ), strtotime( $note->comment_date ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<div class="woocommerce-OrderUpdate-description description">
<?php echo wpautop( wptexturize( $note->comment_content ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</li>
<?php endforeach; ?>
</ol>
<?php endif; ?>
It shows the notes I can send to customer in WC orders. That info is under My account -> orders -> view order for the customer but I'd like to display that note in customer dashboard instead of view order.
I tried copying it to the dashboard.php but it just threw an error and said that get_customer_order_notes() is null.
I'm a beginner in php and it's my first WC site so any help would be much appreciated.
my goal is to move the checkout user registration form to the top of the checkout page (Above the billing form)...
I'm stuck on finding the correct variables and names to hook this form to the place I desire.
Any advice is appreciated! Thank you
You could modify form-billing.php template.
move the following code to the top or the place you want.
<?php if ( ! is_user_logged_in() && $checkout->is_registration_enabled() ) : ?>
<div class="woocommerce-account-fields">
<?php if ( ! $checkout->is_registration_required() ) : ?>
<p class="form-row form-row-wide create-account">
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
<input class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" id="createaccount" <?php checked( ( true === $checkout->get_value( 'createaccount' ) || ( true === apply_filters( 'woocommerce_create_account_default_checked', false ) ) ), true ) ?> type="checkbox" name="createaccount" value="1" /> <span><?php _e( 'Create an account?', 'woocommerce' ); ?></span>
</label>
</p>
<?php endif; ?>
<?php do_action( 'woocommerce_before_checkout_registration_form', $checkout ); ?>
<?php if ( $checkout->get_checkout_fields( 'account' ) ) : ?>
<div class="create-account">
<?php foreach ( $checkout->get_checkout_fields( 'account' ) as $key => $field ) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>
<div class="clear"></div>
</div>
<?php endif; ?>
<?php do_action( 'woocommerce_after_checkout_registration_form', $checkout ); ?>
</div>
<?php endif; ?>
I want to stop WordPress re-ordering the category list in the admin > post edit page. The default behaviour is to take the categories assigned to the post out of their natural parent/child flow and put them at the top of the list. I want to stop this happening as it is confusing when the category structure is big.
Any thoughts?
Thanks.
While the above are great alternative solutions, especially if you want more control over the taxonomy checklist metabox, I think the simplest solution would be the following:
function taxonomy_checklist_checked_ontop_filter ($args)
{
$args['checked_ontop'] = false;
return $args;
}
add_filter('wp_terms_checklist_args','taxonomy_checklist_checked_ontop_filter');
And that should take care of that!
What version of Wordpress are you using? Wordpress 3.04 provides the Parent/Child tree on the Post Edit page. Are you sure you also aren't viewing the "Most Used" tab?
Nevermind, I see exactly the problem you are talking about, which show up after the post is saved:
Alright, try pasting this into the functions.php in your theme:
// remove the old box
function remove_default_categories_box() {
remove_meta_box('categorydiv', 'post', 'side');
}
add_action( 'admin_head', 'remove_default_categories_box' );
// add the new box
function add_custom_categories_box() {
add_meta_box('customcategorydiv', 'Categories', 'custom_post_categories_meta_box', 'post', 'side', 'low', array( 'taxonomy' => 'category' ));
}
add_action('admin_menu', 'add_custom_categories_box');
/**
* Display CUSTOM post categories form fields.
*
* #since 2.6.0
*
* #param object $post
*/
function custom_post_categories_meta_box( $post, $box ) {
$defaults = array('taxonomy' => 'category');
if ( !isset($box['args']) || !is_array($box['args']) )
$args = array();
else
$args = $box['args'];
extract( wp_parse_args($args, $defaults), EXTR_SKIP );
$tax = get_taxonomy($taxonomy);
?>
<div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv">
<ul id="<?php echo $taxonomy; ?>-tabs" class="category-tabs">
<li class="tabs"><?php echo $tax->labels->all_items; ?></li>
<li class="hide-if-no-js"><?php _e( 'Most Used' ); ?></li>
</ul>
<div id="<?php echo $taxonomy; ?>-pop" class="tabs-panel" style="display: none;">
<ul id="<?php echo $taxonomy; ?>checklist-pop" class="categorychecklist form-no-clear" >
<?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?>
</ul>
</div>
<div id="<?php echo $taxonomy; ?>-all" class="tabs-panel">
<?php
$name = ( $taxonomy == 'category' ) ? 'post_category' : 'tax_input[' . $taxonomy . ']';
echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
?>
<ul id="<?php echo $taxonomy; ?>checklist" class="list:<?php echo $taxonomy?> categorychecklist form-no-clear">
<?php
/**
* This is the one line we had to change in the original function
* Notice that "checked_ontop" is now set to FALSE
*/
wp_terms_checklist($post->ID, array( 'taxonomy' => $taxonomy, 'popular_cats' => $popular_ids, 'checked_ontop' => FALSE ) ) ?>
</ul>
</div>
<?php if ( !current_user_can($tax->cap->assign_terms) ) : ?>
<p><em><?php _e('You cannot modify this taxonomy.'); ?></em></p>
<?php endif; ?>
<?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
<div id="<?php echo $taxonomy; ?>-adder" class="wp-hidden-children">
<h4>
<a id="<?php echo $taxonomy; ?>-add-toggle" href="#<?php echo $taxonomy; ?>-add" class="hide-if-no-js" tabindex="3">
<?php
/* translators: %s: add new taxonomy label */
printf( __( '+ %s' ), $tax->labels->add_new_item );
?>
</a>
</h4>
<p id="<?php echo $taxonomy; ?>-add" class="category-add wp-hidden-child">
<label class="screen-reader-text" for="new<?php echo $taxonomy; ?>"><?php echo $tax->labels->add_new_item; ?></label>
<input type="text" name="new<?php echo $taxonomy; ?>" id="new<?php echo $taxonomy; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" tabindex="3" aria-required="true"/>
<label class="screen-reader-text" for="new<?php echo $taxonomy; ?>_parent">
<?php echo $tax->labels->parent_item_colon; ?>
</label>
<?php wp_dropdown_categories( array( 'taxonomy' => $taxonomy, 'hide_empty' => 0, 'name' => 'new'.$taxonomy.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $tax->labels->parent_item . ' —', 'tab_index' => 3 ) ); ?>
<input type="button" id="<?php echo $taxonomy; ?>-add-submit" class="add:<?php echo $taxonomy ?>checklist:<?php echo $taxonomy ?>-add button category-add-sumbit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" tabindex="3" />
<?php wp_nonce_field( 'add-'.$taxonomy, '_ajax_nonce-add-'.$taxonomy, false ); ?>
<span id="<?php echo $taxonomy; ?>-ajax-response"></span>
</p>
</div>
<?php endif; ?>
</div>
<?php
}
The only real change was adding 'checked_ontop' => FALSE to the args in wp_terms_checklist() function in the middle of that mess. Everything else is the original post_categories_meta_box() function.
(You could just modify the original post_categories_meta_box() in /wp-admin/includes/meta-boxes.php, but it is not recommended to mess with core and adding/removing actions as above is the proper way to do it.
There's a plugin that does just this http://wordpress.org/extend/plugins/category-checklist-tree/
I'm trying to add pagination to my wordpress search results.
I was able to locate some information on how to do this - http://codex.wordpress.org/Function_Reference/paginate_links
But I've run into a problem that I can't explain.
The Pagination is being added to the bottom of the search results page and the number of pages does change depending on what search term I use. If you click the next button or select a page number the url changes but the search results don't...
I'm only able to have the first 10 result appear on the page, even if I click page 4, the page will refresh but it still displaying the original 10 results.
Does anyone know how I could fix this?
Here's my code
<?php
get_header();
iinclude_page(608); ?>
<li id="search">
<form id="searchform" method="get" action="<?php bloginfo('home'); ?>">
<div style="text-align:center; margin:20px 0 25px 0;">
<label style="font-weight:bold;" for="s"><?php _e('Search Database:'); ?></label> <input type="text" name="s" id="s" size="20" /> <?php $args = array('hide_empty'=>0,'depth'=>2,'hierarchical'=> 1, );
wp_dropdown_categories($args); ?> <input type="submit" value="<?php _e('Search'); ?>" />
</div>
</form>
</li>
<hr />
<?php
if (have_posts()): ?>
<?php
while (have_posts()) : the_post(); ?>
<li class="postWrapper" id="post-<?php the_ID(); ?>">
<h3 class="entry-title"><?php the_title(); ?></h3>
<div id="postdata">
<div class="search-content">
<?php the_excerpt(__('<p>Read More ></p>')); ?>
</div>
<div class="entry-meta">
<?php
$view_in_browser = '<a class="google-viewer" href="http://docs.google.com/viewer?url='.$attachment_url.'">View document in browser</a>';
$download = '<a class="download" href="'.$attachment_url.'">Download PDF</a>';
echo $view_in_browser . ' ' . $download;
?>
</div>
</div>
<hr />
</li>
<?php endwhile; ?>
<?php
global $wp_rewrite;
$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
$pagination = array(
'base' => #add_query_arg('page','%#%'),
'format' => '',
'total' => $wp_query->max_num_pages,
'current' => $current,
'show_all' => true,
'type' => 'plain',
);
if( $wp_rewrite->using_permalinks() )
$pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg('s',get_pagenum_link(1) ) ) . 'page/%#%/', 'paged');
if( !empty($wp_query->query_vars['s']) )
$pagination['add_args'] = array('s'=>get_query_var('s'));
echo paginate_links($pagination);
?>
<?php else: ?>
<h3 style="text-align:center; font-weight:bold; color:#333;"><?php _e('Sorry, no posts matched your criteria.'); ?></h3>
<p style="text-align:center">Please try Searching anohter term.</p>
<?php
endif;
?>
<?php if (will_paginate()): ?>
<?php endif; ?>
<?php
get_footer();
?>
It probably depends on your query and it probably revolves around not using the $paged correctly (cant see your code)
Probably you have one of the 2 improvement to be made in your code:
See: https://wordpress.stackexchange.com/questions/2638/pagination-resolving-to-first-page-only
OR: https://wordpress.stackexchange.com/questions/4368/authors-list-pagination-result-set-from-wpdb-get-results/4370#4370
(and more hits on http://wordpress.stackexchange.com ................)
I was on the search for exactly the same, but couldn't find anything that offered a simple template tag with a semantically correct output (ul) that works well for seo, so i wrote my own one: Easy Pagination Deamon
I need to display link after each comment, when you click that link, a new page displays that single coment on a new page.
Is that possible?
I answered your exact question over on WordPress Answers (also a StackExchange site) just yesterday. You can find that answer here. It involved the following four steps:
Setting up the URL Rewriting by adding a query_var, rewrite_tag and a permastruct,
Being sure to flush the rewrite rules in a plugin's activation hook or manually,
Adding a parse_query filter hook to set the query_vars's post to be the comment's post and to disable sticky posts for the query,
Adding a template_include filter hook to filter the template file name to load a template specific template file for a single comment, and lastly
To create the comment template file as /wp-content/themes/%your-theme%/comment.php.
Again, you can find the answer over here.
Hope this helps.
-Mike
UPDATE:
Below is the full content that I had also posted on WordPress Answers:
There are numerous different ways to accomplish this, some more polished than others and practically all of them with potential for conflict with other plugins, but ignoring all that here's one way that is pretty close to what you asked for. :)
This solution will support a URL format like the following where %comment_id% is the numeric ID of your comment from the wp_comments table:
http://example.com/comments/%comment_id%/
First you'll need to configure your URL rewriting using the following code. Hopefully it is reasonably self-explanitory but don't hesitate to ask:
$wp->add_query_var('comment_id'); // Add the "behind-the-scenes" query variable that WordPress will use
$wp_rewrite->add_rewrite_tag('%comment_id%', '([0-9]+)','comment_id='); // Define a rewrite tag to match that assigns to the query var
$wp_rewrite->add_permastruct('comment-page', 'comments/%comment_id%'); // Define a URL pattern to match the rewrite tag.
You'll also either need to call this code in a plugin activation hook to flush the rules, or if it's your site you can just save permalinks in the admin console's Settings > Permalinks settings area:
global $wp_rewrite;
$wp_rewrite->flush_rules(false);
Next add a parse_query filter hook. This will be called after WordPress has inspected the query. It tests to see if your added comment_id query_var set and if so it tests to see if you are on the desired URL. If yes then it loads the comment array using get_comment() in order to set the 'p' parameter (which should be set to a post ID) to the post that is related to the comment. That way when WordPress runs the query that it is going to run no matter what at least it loads something you'll need in your comment.php theme template file below and you won't have to ran another query later when you need it. This code also tells WordPress to ignore sticky posts using the oddly named caller_get_posts option:
add_filter( 'parse_query', 'my_parse_query' );
function my_parse_query( $query ) {
global $wp;
if (isset($query->query['comment_id']) && substr($wp->request,0,9)=='comments/') {
$comment = get_comment($query->query['comment_id']);
$query->query_vars['p'] = $comment->comment_post_ID; // Causes the comment's post to be loaded by the query.
$query->query_vars['caller_get_posts'] = true; // Keeps sticky posts from invading into the top of our query.
}
}
Still next you'll need to hook the code in /wp-includes/template-loader.php using the template_include filter. This will be called after WordPress has both inspected the query and loaded the post for the comment. Here you'll first check again for comment_id in the query_var and also for the URL being the one you want. If so we replace the /index.php template page with /comment.php which is a theme template file you will need to create:
add_filter( 'template_include', 'my_template_include' );
function my_template_include( $template ) {
global $wp,$wp_query;
if (isset($wp_query->query['comment_id']) && substr($wp->request,0,9)=='comments/') {
$template = str_replace('/index.php','/comment.php',$template);
}
return $template;
}
Lastly now you need to create your theme template file which I've chosen to call /comment.php. Since it's your theme you'll want to make it look like you want but here is an example to get you started:
<?php
/*
* File: /wp-content/themes/my-theme/comment.php
*/
global $wp_query,$post;
$comment_id = $wp_query->query['comment_id'];
$comment = get_comment($comment_id);
$permalink = get_permalink($post->ID);
get_header();
?>
<div id="container">
<div id="comment-<?php echo $comment_id; ?>" class="comment">
<p>Comment by: <span class="comment-author">
<?php echo $comment->comment_author; ?></span>
on <span class="comment-date"><?php echo date("D M jS Y", strtotime($comment->comment_date)); ?></span>
at <span class="comment-time"><?php echo date("h:ia", strtotime($comment->comment_date)); ?></span>
</p>
<p>About: <?php echo $post->post_title; ?></p>
<blockquote><?php echo $comment->comment_content; ?></blockquote>
</div>
</div>
<?php
get_sidebar();
get_footer();
Any questions? Just ask.
Hope this helps.
P.S. All of the code I describing above can either go in your theme's functions.php file and/or in a plugin of your own. A caveat is for the URL rewrite flushing rules that should go in a plugin activation hook if you are going to include it instead us just flushing them manually in the permalinks section of the admin console. I didn't show how to register an activation hook do but if you want to learn more you can read about it here.
(New edited version after OP's comments)
There are many ways to do this. In theory this is the simplest, but maybe not 'most appropriate according to WordPress' way. Take this as a starting point. I haven't tested it, so you may encounter an error or two that should be solvable with some minor tweaks. Let me know if you get stumped and I'll do my best. So conceptually...
You should copy the page.php template file and rename it to 'comments_page.php' (or whatever you like). Open this file in your code editor and find where the following appears: (or create it if it does not exist)
/*Template Name: page*/
and change it to
/*Template Name: comments_page*/
Now open your WordPress admin area and create a new page. Call it whatever you want but don't add any content. In the right hand column, select the template that the page uses from the "Page Template" drop down menu. Select 'comments_page' (or whatever you listed as the template name). This tells WordPress to use your file to show this specific page instead of the default page template. Save the page and note the page_id that WordPress generates.
Now, find your theme's comments template, usually 'comments.php'. Find the function wp_list_comments();. We are going to add the name of a custom function that will control the display of your comments as an argument to this function. For an example, go to the twenty-ten theme's files, open comments.php and you'll see what that looks like:
wp_list_comments( array( 'callback' => 'twentyten_comment' ) );
Open the twenty-ten theme's functions.php and find
function twentyten_comment()
Copy that entire function and paste it into your theme's functions file. Change the name to' my_comment()', and add that to the wp_list_comments function call like this:
wp_list_comments( array('callback'=>'my_comment'));
In your newly-created 'my_comment()' function in your functions.php file, add a link where you want to the separate page of comments (comments_page.php) using get_page_link() and a query var named 'commentID' and the comments ID.
View this comment
Now to inappropriately add php logic to a template file. Once you understand how this works, you can create a function in your functions.php file and then call it in the theme file...
On comments_page.php ,use $_GET['commentID'] to retrieve the comment's id value from the url, and pass it to get_comment($commentID) to retrieve the single comment and display it on a single page.
if(isset($_GET['commentID'])){$commentID = $_GET['commentID'];}
$comment = get_comment($commentID);
Now you have all the single comments information in the $comment variable as an object.
You can decide how to display the comment, but to start, I recommend copying the contents of your theme's comments template to keep things consistent. It will show exactly the same thing the post page shows, but it sounds like this page is intended more for the permalink to a single comment that you link to from somewhere else.
Hope this helps. Let me know if you run into a snag.
Note: this answer provides info given to me from Todd Perkins over at wordpress.stackexchange.com
This is my functions.php
<?php
if ( ! function_exists( 'twentyten_comment' ) ) :
function my_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case '' :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="comment-author vcard">
<?php echo get_avatar( $comment, 40 ); ?>
<?php printf( __( '%s <span class="says">says:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
</div><!-- .comment-author .vcard -->
<?php if ( $comment->comment_approved == '0' ) : ?>
<em><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: date, 2: time */
printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
?>
</div><!-- .comment-meta .commentmetadata -->
<div class="comment-body"><?php comment_text(); ?></div>
View this comment
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div><!-- .reply -->
</div><!-- #comment-## -->
<?php
break;
case 'pingback' :
case 'trackback' :
?>
<li class="post pingback">
<p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'twentyten'), ' ' ); ?></p>
<?php
break;
endswitch;
}
endif;
This is my comments_page.php
/*Template Name: comments_page*/
<? if(isset($_GET['commentID'])){$commentID = $_GET['commentID'];}
$comment = get_comment($commentID);
?>
<?php get_header(); ?>
<div id="content">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post">
<!--uncomment for header tags-- <h1><?php the_title(); ?></h1>
<small><b>Posted:</b> <?php the_time('F jS, Y') ?> | <b>Author:</b> <?php the_author_posts_link(); ?> | <b>Filed under:</b> <?php the_category(', ') ?> <?php the_tags(' | <b>Tags:</b> ', ', ', ''); ?> <?php if ( $user_ID ) :
?> | <b>Modify:</b> <?php edit_post_link(); ?> <?php endif; ?>| <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></small> -->
<?php the_content('Read the rest of this entry »'); ?>
<hr/>
</div>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
</div>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
This is my comments.php
<?php // Do not delete these lines
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('Please do not load this page directly. Thanks!');
if (!empty($post->post_password)) { // if there's a password
if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
?>
<p class="nocomments">This post is password protected. Enter the password to view comments.</p>
<?php
return;
}
}
/* This variable is for alternating comment background */
$oddcomment = 'class="alt" ';
?>
<!-- You can start editing here. -->
<div id="comments">
<?php if ($comments) : ?>
<h3><?php comments_number('No Comments', 'One Comment', '% Comments' );?> on “<?php the_title(); ?>”</h3>
<?php wp_list_comments( array('callback'=>'my_comment')); ?>
<?php else : // this is displayed if there are no comments so far ?>
<?php if ('open' == $post->comment_status) : ?>
<!-- If comments are open, but there are no comments. -->
<?php else : // comments are closed ?>
<!-- If comments are closed. -->
<p class="nocomments">Comments are closed.</p>
<?php endif; ?>
<?php endif; ?>
<?php if ('open' == $post->comment_status) : ?>
<hr/>
<h4 class="center">Leave a Reply</h4>
<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
<p>You must be logged in to post a comment.</p>
<?php else : ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<ul class="formlist">
<?php if ( $user_ID ) : ?>
<p>Logged in as <?php echo $user_identity; ?>. Log out »</p>
<?php else : ?>
<li><input type="text" name="author" id="author" value="Name <?php if ($req) echo "(required)"; ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> onblur="if(this.value.length == 0) this.value='Name <?php if ($req) echo "(required)"; ?>';" onclick="if(this.value == 'Name <?php if ($req) echo "(required)"; ?>') this.value='';" /></li>
<li><input type="text" name="email" id="email" value="Mail (will not be published) <?php if ($req) echo "(required)"; ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> onblur="if(this.value.length == 0) this.value='Mail (will not be published) <?php if ($req) echo "(required)"; ?>';" onclick="if(this.value == 'Mail (will not be published) <?php if ($req) echo "(required)"; ?>') this.value='';" /></li>
<li><input type="text" name="url" id="url" value="Website" size="22" tabindex="3" onblur="if(this.value.length == 0) this.value='Website';" onclick="if(this.value == 'Website') this.value='';" /></li>
<?php endif; ?>
<!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>-->
<li><textarea name="comment" id="comment" cols="70%" rows="10" tabindex="4" value="Enter comment here."></textarea></li>
<li class="submitbutton"><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" /></li>
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
<?php do_action('comment_form', $post->ID); ?>
</ul>
</form>
<?php endif; // If registration required and not logged in ?>
<?php endif; // if you delete this the sky will fall on your head ?>
</div>