The following tutorial is about designing your own single.php page in wordpress theme.

In WordPress theme, Single.php used to display the single post with the author information, comment and reply section.

First create a blank php file and save as single.php. Then copy all the code from index.php file and paste it to single.php file. Now delete all code in between “<div id=”container”>.” tag and replace the code below:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<div <?php post_class() ?>>

<h2><?php the_title(); ?></h2>

<ul class="postmetadata clearfix">

<li class="author">By <?php the_author_posts_link(); ?></li>

<li><?php the_time('l, F jS, Y') ?></li>

<li><?php the_category(', ') ?></li>

</ul>

<div><div id="post_thumb"><?php the_post_thumbnail(); ?></div>

<!--/post_thumb-->

<?php the_content('<p class="serif">Read More &raquo;</p>'); ?>

<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

<?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>

<?php if(function_exists('wp_print')) { print_link(); } ?>

</div>

</div>

Now add author profile box including author name, author bio. Copy and paste the code below:

<!--author box-->

<div>

<?php echo get_avatar( get_the_author_email(), $size = '80'); ?>

<div class="authortext">

<h4>About <?php the_author_posts_link(); ?></h4>

<p><?php the_author_description(); ?></p>

</div>

</div>

<!--/authorbox-->

Author Info Box


The single post page with author name and bio becomes complete with it. Now you have to add comments section to our Post. Just copy and paste just under author box in this code:

<?php comments_template(); ?>

<?php endwhile; else: ?>

<p>Sorry, no posts matched your criteria.</p>

<?php endif; ?>

Along with the header, sidebar, footer and comments our single.php page is ready.

Categories: Tutorials, Wordpress

About

He is a freelance graphic designer with more than 15 years of design experience, including both print and web design.

.. Write a Guest Post ..

Comments are closed.

Copyright © 2017 gopalbonline.com