Categories Site Actions X

Adding a Source Bar in WordPress

Posted on Friday, May 27th, 2011 in Uncategorized by Nick

After including the source of information for articles, I wanted to make a more permanent solution. Using a custom field and a few lines of code, you can have your own source bar on your WordPress blog.

Step 1: Create a Custom Field

When creating a new post, scroll down to custom field and add a new field called ‘source’. The value is the url to the source (ex. http://usatoday.com/somearticle).

Step 2: PHP

Open up single.php and find:

the_content();

Add the following after it:

 $cfield = get_post_custom_values("source");
if (isset($cfield[0])) {
  echo '';
}


Step 3: CSS

Now open up stylesheet.css and add the following:

#source{ 
       background:#f1f1f1;
       border:solid 1px #dfdfdf;
       width:560px;
       padding:8px;
       margin-bottom:30px;
       display:block;
       color:#7d7d7d;
}

I placed a demonstration at the bottom of the post

Leave a Reply

Join the forum to add your own thoughts!