Wordpress Snippets

Add Custom Status or Notes to a WordPress 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).


ID, "note", true) ): ? >

Posted From: ID, “note”, true); ? >

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! 🙂

Hire Us. Or just say Hi!
Need a job? Apply to get one.