[Tutorial #24] Single Post

[Tutorial #24] Single Post

Introduction

In this tutorial we examine the templates and plugins used for displaying a single post. After this we are ready to create blog content for our site!

Single Post Templates

When wordpress displays a single post (by clicking on the post link) it renders the post via template single.php. Below is the template code. You can also get it on my Github page.

The codes are just a subset of the more complicated category.php file. We have:

  • Line 7, 36: header and footer inclusion.
  • Line 14: Bootstrap column classes.
  • Line 15-16: the Loop. For single post there is really no loop action as there is only one post.
  • Line 17: partial template content-single.php inclusion.
  • Line 22-27: standard way to include wordpress commenting elements.

single.php uses the partial template content-single.php:

content-single.php is almost the same as content.php. The major difference is now we show the whole content via the_content() at line 47 instead of excerpt. See this tutorial to learn more about content.php.

Plugins

There are a lot of free plugins to enhance post editing and viewer experience. For ModernBlackHand we use the following post-related plugins:

Table of Content

We use a simple Better Anchor Links to display a post’s table of content. It has several nice features like indentation and header selection.

wp plugin better anchor links

Editor Enhancement

A nice plugin to enhance wordpress’ post editor is TinyMCE Advanced.

wp plugin tinymce

Another great plugin for displaying chunk of codes is Crayon Syntax Highlighter:

wp plugin crayon

Comments

An alternative commenting system is Disqus’ wordpress plugin. Using Disqus users can login with various social media accounts.

wp plugin disqus