phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Wordpress - Theme: Showing Comments at Single Post

Tag: wordpress, theme, comments   Category: Web Design, PHP Application
post: 04 Feb 2008 read: 1,478


Wordpress Theme step by step tutorial - Part 17: After modify single post, now, its time for us to show comments. For this job, first, we need a new file named "comments.php" within wp-content/themes/crown.

wordpress theme showing comments


<? if ( $comments ): ?>
<ol id="commentlist">
  <? foreach ($comments as $comment): ?>
    <li id="comment-<? comment_ID() ?>">
    <? comment_text(); ?>
    <p>
        <cite>
        <? comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?>
        <? _e('by') ?>
        <? comment_author_link() ?> —
        <? comment_date() ?> @
        <a href="#comment-<? comment_ID() ?>">
        <? comment_time() ?>
        </a>
        </cite>
        <? edit_comment_link(__("Edit This"), ' |') ?>
    </p>
  <? endforeach; ?>
</ol>
<? else : ?>
<p><? _e('No comments.'); ?></p>
<? endif; ?>

Then, edit your "single.php". Add following code in box:

wordpress theme showing comments


<? get_header(); ?>
  <div class="separator">
  </div>
  <div id="post_container">
    <div id="left_part">
<? if(have_posts()): ?>
  <? while(have_posts()): ?>
    <? the_post() ?>
    <h1>
      <a href='<?=the_permalink()?>'><?=the_title()?></a>
    </h1>
    <? _e("Posted "); ?> by <? the_author(); ?> at
    <? the_time('F js, Y') ?>
    <? the_content("more"); ?>
<? comments_template(); ?>    
  <? endwhile; ?>
<? endif; ?>
    </div>
	<? get_sidebar(); ?>
    <div class="separator">
    </div>
<? get_footer(); ?>

The result like this:

wordpress theme showing comments


Series this article:
Wordpress - Theme: Installing and Changing Theme
Wordpress - Theme: Building Your Own Theme
Wordpress - Theme: Writing First Code
Wordpress - Theme: Wordpress Code Style
Wordpress - Theme: Showing the Post Excerpt on the Front Page
Wordpress - Theme: Showing Category Name for Each Post
Wordpress - Theme: Showing a Post with Date and Author
Wordpress - Theme: Planning Theme Design
Wordpress - Theme: Writing Basic Code for Two Column
Wordpress - Theme: Splitting Index Become Some Small Parts
Wordpress - Theme: Uniting Various Small Parts
Wordpress - Theme: Separating Stylesheet From Header
Wordpress - Theme: Designing Simple Header
Wordpress - Theme: Placing Content to Body
Wordpress - Theme: Showing Archives, Categories, Links in Side bar
Wordpress - Theme: Creating Footer
Wordpress - Theme: Modifying Single Post Display
Wordpress - Theme: Showing Comments at Single Post
Wordpress - Theme: Showing Comment Form
WordPress - Theme: Showing Trackback,RSS, and Other Detail at Single Post
WordPress - Theme: Showing Title and Other HTML Header
WordPress - Theme: Making Theme Widget Enabled

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


619
posting