Nav: (Display/Hide) - Home - About the Author / this page

Current Projects: Americana Engine (Game Engine Development)

Wednesday, October 17, 2012

Creating separate Post Excerpts and Full Post Content

Sometimes there are occasions where you want the a blog excerpt to be different than just the beginning of a post when users browse through archives. This post explains how to do just that.

I discovered how to do this while trying to find ways to hide certain content on a blog post, and also because I didn't like the way some articles read 'post after the break' like you were reading it from a RSS reader and the same text showing up on the post itself. Having only excerpts prevents people casually scrolling through the blog and reading all the content in one go, and instead clicking 'read more' if interested - this allows me to see what types of posts people are reading, and what to post more of.

1. Insert the following code at the beginning of the post:

 <span id="customexcerpt">Enter Post Summary Here</span>

<!-- more -->

<style type="text/css">
#erhide {display:none;}

2. Change the 'Enter Post Summary Here' with what you want your excerpt to say.

3. Insert the rest of your post data after that.

You are set - the post summary will be different than the rest of your post.

Although this will make the data hidden from both the actual post and a RSS reader (if you set the RSS feed display to Full, at least on Blogger), if one were to copy the entire post it would also display the hidden excerpt data. Therefore it's recommended that it's used for images or for coherent posts.