Single static page with comments template
-
I am trying to build a new page template that will allow me to edit content in the admin dashboard for the static page but also allow comments. any thoughts?
-
I think it’s a good thing 🙂
What problem are you facing?
Peter
I am learning html and css/php. I am editing the link template and have the comments code in but i cannot find the code to grab the content from the admin dashboard. I would like to be able to make new pages then apply the new content and allow comments on the page.
Sounds like you’re missing the Loop. Have you looked at http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates
Hmmm, not quite sure I do understand:
A minimal WordPress theme only needs an index.php, but to show posts on its own, one uses single.php. To display pages, one uses page.php.
The latter would be the one to edit, but, if you want comment fields on only certain pages, one could create another template for such a page, say you want your ‘about’ page to be different from the other pages, you would also create an about.php template.
If you want several pages to look the same, you would probably be needing custom page templates.
The code to display the actual page contents, is described here, and is basically the same for each template.
Peter
Here is what i have so far. I am getting it together but just need to figure out how to size everything so it fits properly.
<?php
/*
Template Name: Perks Page Temp
*/
?><?php get_header(); ?>
<div id=”content” class=”580px”>
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<div class=”post”>
<h2 id=”post-<?php the_ID(); ?>”><?php the_title();?></h2>
<div class=”entrytext”>
<?php the_content(‘<p class=”serif”>Read the rest of this page »</p>’); ?>
</div>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link(‘Edit this entry.’, ‘<p>’, ‘</p>’); ?></div>
<div id=”main”><?php
/**
* @package WordPress
* @subpackage Default_Theme
*/// 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 ( post_password_required() ) { ?>
<p class=”nocomments”>This post is password protected. Enter the password to view comments.</p>
<?php
return;
}
?><div id=”comments” class=”post-box”>
<div class=”comment-content”>
<div class=”comment-count”>
<?php comments_number(‘0 Comments’, ‘1 Comment’, ‘% Comments’ );?>
</div><?php if ( have_comments() ) : ?>
<ol class=”commentlist clearfix”>
<?php wp_list_comments( ‘callback=magazeen_comment’ ); ?><?php else : ?>
<?php if (‘open’ == $post->comment_status) : ?>
<ol class=”commentlist”>
<li class=”no-comments”>
<p>It‘s quite in here! Why not tell us about your experience response?</p><?php else : ?>
<p class=”nocomments”>Comments are closed.</p>
<?php endif; ?>
<?php endif; ?></div>
</div>
<?php echo $page ?>
<?php if( get_previous_comments_link() || get_next_comments_link() ) : ?>
<div class=”navigation arial clearfix”>
<div class=”alignleft”><?php previous_comments_link(); ?></div>
<div class=”alignright”><?php next_comments_link(); ?></div>
</div><?php endif; ?>
<?php if (‘open’ == $post->comment_status) : ?>
<div id=”respond” <?php post_class( ); ?> style=”margin-top:10px; padding:15px;”>
<div class=”post-meta clearfix”>
<h3 class=”post-title-small left”>Leave a Response</h3>
<p class=”post-info right”>
<small><?php cancel_comment_reply_link(); ?></small>
</p></div><!– End post-meta –>
<div class=”post-box”>
<div class=”page-content”>
<?php if ( get_option(‘comment_registration’) && !$user_ID ) : ?>
<p>You must be /wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>”>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 /wp-admin/profile.php”><?php echo $user_identity; ?>. ” title=”Log out of this account”>Log out »</p>
<?php else : ?>
<p><input type=”text” name=”author” id=”author” value=”<?php echo $comment_author; ?>” size=”32″ tabindex=”1″ class=”input” <?php if ($req) echo “aria-required=’true'”; ?> />
<label for=”author”><small>Name <?php if ($req) echo “(required)”; ?></small></label></p><p><input type=”text” name=”email” id=”email” value=”<?php echo $comment_author_email; ?>” size=”32″ tabindex=”2″ class=”input” <?php if ($req) echo “aria-required=’true'”; ?> />
<label for=”email”><small>eMail (will not be published) <?php if ($req) echo “(required)”; ?></small></label></p><?php endif; ?>
<p><textarea name=”comment” id=”comment” cols=”” rows=”10″ tabindex=”4″ class=”input” style=”width:95%; display:inline;”></textarea></p>
<p><input name=”submit” type=”submit” class=”submit-comment” id=”submit” tabindex=”5″ value=”Submit Comment” />
<?php comment_id_fields(); ?>
</p>
<?php do_action(‘comment_form’, $post->ID); ?></form>
<?php endif; // If registration required and not logged in ?>
</div>
</div>
</div>
<?php endif; // if you delete this the sky will fall on your head ?>
<?php get_footer(); ?>
Ok progress. i cannot seem to get the footer to fill out tot the edges and the comments are not showing up. please help.
<?php
/*
Template Name: Perks Page Temp
*/
?><?php get_header(); ?>
<div id=”main-content” class=”clearfix”>
<div class=”container”>
<div class=”col-580 left”>
<div id=”content” class=”widecolumn”>
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<div class=”post”>
<h2 id=”post-<?php the_ID(); ?>”><?php the_title();?></h2>
<div class=”entrytext”>
<?php the_content(‘<p class=”serif”>Read the rest of this page »</p>’); ?>
</div>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link(‘Edit this entry.’, ‘<p>’, ‘</p>’); ?></div>
<div id=”main”><?php
/**
* @package WordPress
* @subpackage Default_Theme
*/// 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 ( post_password_required() ) { ?>
<p class=”nocomments”>This post is password protected. Enter the password to view comments.</p>
<?php
return;
}
?><div id=”comments” class=”post-box”>
<div class=”comment-content”>
<div class=”comment-count”>
<?php comments_number(‘0 Comments’, ‘1 Comment’, ‘% Comments’ );?>
</div><?php if ( have_comments() ) : ?>
<ol class=”commentlist clearfix”>
<?php wp_list_comments( ‘callback=magazeen_comment’ ); ?><?php else : ?>
<?php if (‘open’ == $post->comment_status) : ?>
<ol class=”commentlist”>
<li class=”no-comments”>
<p>It‘s quite in here! Why not tell us about your experience response?</p><?php else : ?>
<p class=”nocomments”>Comments are closed.</p>
<?php endif; ?>
<?php endif; ?></div>
</div>
<?php echo $page ?>
<?php if( get_previous_comments_link() || get_next_comments_link() ) : ?>
<div class=”navigation arial clearfix”>
<div class=”alignleft”><?php previous_comments_link(); ?></div>
<div class=”alignright”><?php next_comments_link(); ?></div>
</div><?php endif; ?>
<?php if (‘open’ == $post->comment_status) : ?>
<div id=”respond” <?php post_class( ); ?> style=”margin-top:10px; padding:15px;”>
<div class=”post-meta clearfix”>
<h3 class=”post-title-small left”>Leave a Response</h3>
<p class=”post-info right”>
<small><?php cancel_comment_reply_link(); ?></small>
</p></div><!– End post-meta –>
<div class=”post-box”>
<div class=”page-content”>
<?php if ( get_option(‘comment_registration’) && !$user_ID ) : ?>
<p>You must be /wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>”>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 /wp-admin/profile.php”><?php echo $user_identity; ?>. ” title=”Log out of this account”>Log out »</p>
<?php else : ?>
<p><input type=”text” name=”author” id=”author” value=”<?php echo $comment_author; ?>” size=”32″ tabindex=”1″ class=”input” <?php if ($req) echo “aria-required=’true'”; ?> />
<label for=”author”><small>Name <?php if ($req) echo “(required)”; ?></small></label></p><p><input type=”text” name=”email” id=”email” value=”<?php echo $comment_author_email; ?>” size=”32″ tabindex=”2″ class=”input” <?php if ($req) echo “aria-required=’true'”; ?> />
<label for=”email”><small>eMail (will not be published) <?php if ($req) echo “(required)”; ?></small></label></p><?php endif; ?>
<p><textarea name=”comment” id=”comment” cols=”” rows=”10″ tabindex=”4″ class=”input” style=”width:95%; display:inline;”></textarea></p>
<p><input name=”submit” type=”submit” class=”submit-comment” id=”submit” tabindex=”5″ value=”Submit Comment” />
<?php comment_id_fields(); ?>
</p>
<?php do_action(‘comment_form’, $post->ID); ?></form>
<?php endif; // If registration required and not logged in ?>
</div>
</div>
</div>
<?php endif; // if you delete this the sky will fall on your head ?>
<?php get_footer(); ?>
Maybe it’s about time you started to provide an URL: it’s way easier to see the site in action and give some meaningful advice.
Peter
got it, my test page is: http://greenzebraconcierge.com/about/my-new-page/
and as i seem to click through the rest of my website I am noticing that the footer is not bleeding out to the edges. Sorry I am such a rookie
The topic ‘Single static page with comments template’ is closed to new replies.