Add Custom Status or Notes to a Post without a Plugin

Think of yourself as a Blogger on the move. You are traveling around the world, sometimes you are at Berlin, and then you move to Paris, yet again to New York.

Wordpress LogoHow cool it would be to add a note to each post that says where you wrote that from? Or maybe you might want to show off your mood, in the mySpace style or insert answers, “What’s on your mind?” or “What are you doing?” with every post.

This can be done using Custom Fields.

Dissection of get_post_meta();

We will use get_post_meta($post_id, $key, $single); for our purpose. It’s a function that’s used to fetch the post meta data.

The code for our use will be:

get_post_meta($post->ID, "note", true);

The post id is the id of the post. It can be any number and the data from the meta of the corresponding post will be used.

In our case, it’s the post that calls the function, use $post->ID. ‘note’ would act as the Custom Field KEY. You can change it to anything you like, and your custom field KEY would be that one.

Insert the following code into any of your post page of your theme file, either single.php or index.php (for StudioPress themes).


< ?php if( get_post_meta($post->ID, "note", true) ): ? >

Posted From: < ?php echo get_post_meta($post->ID, "note", true); ? >

< ?php endif; ? >

The ‘if’ conditions would check if the custom field exists, if it doesn’t exist, nothing will be displayed.

Custom Field for Note

Custom Field for Note

Custom Notes Implemented with some styling on Local Server

Custom Notes Implemented with some styling on Local Server

Have fun! :)



You May Also Like To Read:

  1. Custom Image and Link for Each Post using WordPress Custom Fields
  2. Add the Fast Forward Button Right from the Post Editor
  3. Fixing Missing Excerpts Box, Post Tags Box and Custom Field Box in WordPress
  4. Remove Admin from Recent Comments List (No Plugin)
  5. How To Create Short URL’s on your WordPress Domain without a Plugin or Script

This entry was posted in WordPress and tagged , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

For More Like, "Add Custom Status or Notes to a Post without a Plugin"
Grab the Feed or,

16 Comments

  1. Posted July 5, 2009 at 19:22 | Permalink

    That’s nice, I never thought of this before!

  2. Posted July 5, 2009 at 19:57 | Permalink

    Woow this is amazing trick to show your mood.
    Thanks Arun. :)

  3. Posted July 5, 2009 at 21:14 | Permalink

    Great Find Dude.

  4. Posted July 5, 2009 at 23:22 | Permalink

    I see you are taking up my baton ;-) . Waiting for more stuff like this.

    • Posted July 5, 2009 at 23:26 | Permalink

      Hi hi, I have some plans for the race you just ended, let me complete my lap first ;)

  5. poch
    Posted July 6, 2009 at 07:22 | Permalink

    I hope this great idea works for me Arun. Thanks.

  6. iWrite2Know
    Posted July 6, 2009 at 13:10 | Permalink

    I think this feature will give a big boost to travel blogs and Bloggers who are always on the move. The readers will get hooked on to the blogs to find out the next destination. Amusing!

  7. Posted July 9, 2009 at 22:11 | Permalink

    Great tip Arun.

  8. Vince
    Posted June 29, 2010 at 13:25 | Permalink

    Say my “KEY” is “worked hours” and the value a number, would I be able to add them up based on categories or tags later?
    I’m thinking on applying this for posting tasks on a private blog, each could have a custom field “status” (filed, in progress, on hold , completed) and on completion later on add up a new custom field to the posts for worked hours. But a worked hours “counter” will be nescesary.
    What do you think?

    • Posted July 6, 2010 at 04:21 | Permalink

      The status part could work, the counter, someone would have to manually add that to the custom field. Or better you could use the modified times to get the overall time spent on the post. btw, keys cannot have spaces in between

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting

  • Get Free Updates