What this feature doez is it allows users to display their current mood and the music they were listening to while blogging.
Even though I wouldn’t use this feature on my blog, I figure many bloggers would be interested in knowing how to do this in WordPress.
lets role.....Open your single.php file (or modify your index.php file), and paste the following code anywhere within the loop:
Save the file. Now, when you write a new post, just create a custom field called mood, and type in your current mood as the value.
Note:This is a very basic use of custom fields, not all that different from the well-known hack for displaying thumbnails beside your posts’ excerpts on the home page. It looks for a custom field called mood. If the field is found, its value is displayed.
Even though I wouldn’t use this feature on my blog, I figure many bloggers would be interested in knowing how to do this in WordPress.
lets role.....Open your single.php file (or modify your index.php file), and paste the following code anywhere within the loop:
Code:
$customField = get_post_custom_values("mood"); if (isset($customField[0])) { echo "Mood: ".$customField[0];
}
Save the file. Now, when you write a new post, just create a custom field called mood, and type in your current mood as the value.
Note:This is a very basic use of custom fields, not all that different from the well-known hack for displaying thumbnails beside your posts’ excerpts on the home page. It looks for a custom field called mood. If the field is found, its value is displayed.
Last edited: