WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to add a source link at the end of an article like TechnoBuffalo (scroll down to end of post) with a plugin?

If someone could find a plugin or quickly make one for me that would be great.

share|improve this question
up vote 2 down vote accepted

Thats what meta_boxes are for. First you need to register the metabox within the page or post with the function add_meta_box. Then you want to get that value with get_post_meta on the page where you want the "Source".

This goes into your functions.php file:

/* Define the custom box */
add_action( 'add_meta_boxes', 'wpse_source_link' );

/* Do something with the data entered */
add_action( 'save_post', 'wpse_source_link_save' );

/* Adds a box to the main column on the Post and Page edit screens */
function wpse_source_link() {

        __( 'Source-link', 'myplugin_textdomain' ), 

/* Prints the box content */
function wpse_source_meta_box( $post ) {

  // Use nonce for verification
  wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' );

  // The actual fields for data entry
  echo '<input type="text" id="source-link"" name="source_link" value="'. get_post_meta( $post->ID, '_source_link', true ) .'" size="25" />';

/* When the post is saved, saves our custom data */
function wpse_source_link_save( $post_id ) {
  // verify if this is an auto save routine. 
  // If it is our form has not been submitted, so we dont want to do anything
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 

  // verify this came from the our screen and with proper authorization,
  // because save_post can be triggered at other times

  if ( ! wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename( __FILE__ ) ) )

  // Check permissions

  if ( current_user_can( 'edit_post', $post_id ) ) {

      update_post_meta( $post_id, '_source_link', $_POST['source_link'] );


This code register the meta_box and stores the value in post_meta as "_source_link".

It will look like this:

enter image description here

Then you want to get the value in the post, Use get_post_meta:

<?php echo esc_url( get_post_meta( $post->ID, '_source_link', true ) ); ?>

You should read about: add_meta_boxes, update_post_meta and get_post_meta

share|improve this answer
Thanks for answering, I will have a go with this later. :) – Richard Waterworth Dec 28 '12 at 16:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.