single.php
Description: Displays a single blog post.
This template includes the following templates:
Template Code
<?php get_header() ?>
<div id="container">
<div id="content">
<?php the_post(); ?>
<div id="nav-above" class="navigation">
<div class="nav-previous"><?php previous_post_link('%link', '<span class="meta-nav">«</span> %title') ?></div>
<div class="nav-next"><?php next_post_link('%link', '%title <span class="meta-nav">»</span>') ?></div>
</div>
<div id="post-<?php the_ID(); ?>" class="<?php sandbox_post_class(); ?>">
<h2 class="entry-title"><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(''.__('Read More <span class="meta-nav">»</span>', 'sandbox').''); ?>
<?php wp_link_pages('before=<div class="page-link">' .__('Pages:', 'sandbox') . '&after=</div>') ?>
</div>
<div class="entry-meta">
<?php printf(__('This entry was written by %1$s, posted on <abbr class="published" title="%2$sT%3$s">%4$s at %5$s</abbr>, filed under %6$s%7$s. Bookmark the <a href="%8$s" title="Permalink to %9$s" rel="bookmark">permalink</a>. Follow any comments here with the <a href="%10$s" title="Comments RSS to %9$s" rel="alternate" type="application/rss+xml">RSS feed for this post</a>.', 'sandbox'),
'<span class="author vcard"><a class="url fn n" href="'.get_author_link(false, $authordata->ID, $authordata->user_nicename).'" title="' . sprintf(__('View all posts by %s', 'sandbox'), $authordata->display_name) . '">'.get_the_author().'</a></span>',
get_the_time('Y-m-d'),
get_the_time('H:i:sO'),
the_date('', '', '', false),
get_the_time(),
get_the_category_list(', '),
get_the_tag_list(' '.__('and tagged', 'sandbox').' ', ', ', ''),
get_permalink(),
wp_specialchars(get_the_title(), 'double'),
comments_rss() ) ?>
<?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) : // Comments and trackbacks open ?>
<?php printf(__('<a class="comment-link" href="#respond" title="Post a comment">Post a comment</a> or leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'sandbox'), get_trackback_url()) ?>
<?php elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) : // Only trackbacks open ?>
<?php printf(__('Comments are closed, but you can leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'sandbox'), get_trackback_url()) ?>
<?php elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) : // Only comments open ?>
<?php printf(__('Trackbacks are closed, but you can <a class="comment-link" href="#respond" title="Post a comment">post a comment</a>.', 'sandbox')) ?>
<?php elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) : // Comments and trackbacks closed ?>
<?php _e('Both comments and trackbacks are currently closed.') ?>
<?php endif; ?>
<?php edit_post_link(__('Edit', 'sandbox'), "\n\t\t\t\t\t<span class=\"edit-link\">", "</span>"); ?>
</div>
</div><!-- .post -->
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php previous_post_link('%link', '<span class="meta-nav">«</span> %title') ?></div>
<div class="nav-next"><?php next_post_link('%link', '%title <span class="meta-nav">»</span>') ?></div>
</div>
<?php comments_template(); ?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar() ?>
<?php get_footer() ?>
This template includes the following tags:
__()is a WordPress function used to mark a string for translation to another language. It is similar to_e(), except that__()returns the string while_e()echoes it._e()is a WordPress function used to mark a string for translation to another language. It is similar to__(), except that__()returns the string while_e()echoes it.bloginfo()is a WordPress function that displays information about your blog. Using various parameters, the function can display the following strings:- Blog title;
- Blog tagline;
- Administrator's email address;
- Document content-type;
- Document charset;
- WordPress version;
- Blog URL;
- Pingback URL;
- URL of the RSS 0.92, RSS 1.0, RSS 2.0, or Atom feed;
- URL of the comments feed;
- URL of the directory in which WordPress is installed;
- URL of the current template's directory;
- URL of the current
style.cssfile; - URL of the stylesheet directory (deprecated)
comments_rss()is a WordPress function that generates a link to the comments RSS feed.comments_template()is a WordPress include tag which includes the filecomments.php.edit_post_link()is a Wordpress tag which displays a link to edit the current post (assuming the user is logged in and has the appropriate permissions).get_author_link()has been deprecated. Useget_author_posts_url()instead.get_footeris a WordPress include tag which includes the filefooter.php.get_headeris a WordPress include tag which includes the fileheader.php.get_permalink()is a WordPress function which returns, but does not display, the permalink to a post. It can be used anywhere in a WordPress template.get_sidebaris a WordPress include tag which includes the filesidebar.php.get_the_author()is a WordPress tag which returns the name of the author of the post.get_the_category_list()is a WordPress function which creates a list of categories.get_the_tag_list()is a WordPress tag which generates a list of the tags associated with the current post. This tag must be used within The Loop.get_the_time()is a WordPress tag which returns the time of the current post. It must be used within The Loop.get_the_title()is a WordPress tag which accepts a post ID and returns the title of the post.get_trackback_url()is a WordPress tag.next_post_link()is a WordPress tag which displays a link to the next post. This tag must be used within The Loop.previous_post_link()is a WordPress tag which displays a link to the previous post. This tag must be used within The Loop.printf()is a PHP string function used to output a formatted string.sandbox_post_class()is a Sandbox-specific class defined in thefunctions.phpfile. According to the Sandbox Readme, "It adds semantic classes to each postdivelement, relative to the actual post it contains."sprintf()is a PHP string function which returns a formatted string.the_content()is a Wordpress tag which displays the contents of the current post. This tag must be used within The Loop.the_date()is a WordPress tag which displays or returns the date of a post.the_ID()is a WordPress tag which displays the numeric ID of the current post. It must be within The Loop.the_post()is aWP_Querymethod: "Advance onto the next post, and set the global $post variable."the_title()is a WordPress tag which displays or returns the title of the current post. This tag must be used within The Loop.wp_link_pages()is a WordPress tag which displays page-links for paginated posts. It replaces the deprecatedlink_pages().wp_specialchars()is a WordPress function that is "like the PHP function htmlspecialchars except it doesn't double-encode HTML entities." (Function Reference)
HTML Skeleton
[HEADER.PHP] <div id="container"> <div id="content"> <div id="nav-above" class="navigation"> <div class="nav-previous"> <span class="meta-nav">«</span> Older posts </div> <div class="nav-next"> <span class="meta-nav">»</span> Newer posts </div> </div> <div id="post-[#]" class="hentry p1 post publish author-[AUTHOR] category-recipes tag-[TAG] y[YEAR] m[MONTH] d[DAY] h[HOUR]"> <h2 class="entry-title">[POST TITLE]</h2> <div class="entry-content"> <p>[POST CONTENT]</p> <p><a rel="attachment wp-att-[#]">[IMG]</a></p> </div> <div class="entry-meta"> This entry was written by <span class="author vcard"><a class="url fn n">[AUTHOR]</a></span>, posted on <abbr class="published" title="[DATE]">[MONTH DAY, YEAR] at [TIME]</abbr>, filed under <a rel="category tag">[CATEGORY]</a> and tagged <a rel="tag">[TAG]</a>. Bookmark the <a rel="bookmark">permalink</a>. Follow any comments here with the <a rel="alternate">RSS feed for this post</a>. <a class="comment-link">Post a comment</a> or leave a trackback: <a class="trackback-link" rel="trackback">Trackback URL</a>. <span class="edit-link">[EDIT LINK]</span> </div> </div> <!-- .post --> <div id="nav-below" class="navigation"> <div class="nav-previous"> <span class="meta-nav">«</span> Older posts </div> <div class="nav-next"> <span class="meta-nav">»</span> Newer posts </div> </div> [COMMENTS.PHP] </div> <!-- #content --> </div> <!-- #container --> [SIDEBAR.PHP] [FOOTER.PHP]
Related CSS Styles
Resources
- Creating an Error 404 Page (WordPress.org)