Sometimes it’s handy to be able to show different content in a post when it’s displayed on your homepage, for instance if you post a flash game or movie that you don’t want to start straight away on the main page but want to to load and run fine when the user is viewing the page on it’s own.
Thankfully the answer is extremely simple, we’re going to use custom fields to get the desired effect. First off go into your theme editor and open up the main index template. Now you need to find the PHP function that includes your post, in the default theme it looks like this:
<?php the_content(); ?>
It may look a little different in other themes but it will always be calling the_content, once you’ve found this just add this line above it:
<?php $key=”INDXONLY“; echo get_post_meta($post->ID, $key, true); ?>
Now pop into your add post area and start adding a new post, in the post add <!–more–> at the very top and put anything you want displayed on the full page below it, do not place anything above the <!–more–> tag. This has basically told WordPress to not print anything the post in your page index but only on the single page.
The next thing you need to do is to scroll down and add a custom field, in the “name” field type INDXONLY, then post in all the content you want to be displayed only on the main page into the “Value” field. That’s it! Now when you view your main page you will see only what you put in the custom field, when you click the read more link you will only see the main post and not the custom field.
I use this technique to display flash games in WordPress by taking a screenshot of the game and using that screenshot as my main page content and then the full embed code in the individual page content, meaning that when someone browses the main page they’re not inundated with flash movies loding and playing but when they view the full post it loads straight away.