How to display the Verse of the Day on your Web site

The Verse of the Day is a free service that lets you display an automatically-updating daily Bible verse on your website. This tutorial will show you how to put the Verse of the Day on your website and modify it to display the Bible version and language that you prefer. (The Gospel.com main page features a working example of the Verse of the Day if you want to see one way it can be displayed.)

Important technical note: This tutorial requires that your server be running PHP. If you aren't sure if your server is running PHP, please contact your system administrator.

This tutorial doesn't assume that you're a technical wizard, but does assume that you know a little bit about HTML and modifying your website code.

Follow the steps outlined below to put the Verse of the Day on your website:

  1. Get a copy of Magpie Rss
  2. Add the Verse of the Day code to your website
  3. Customize the Verse of the Day
  4. Put it online

1) Get a copy of Magpie RSS

The Verse of the Day makes use of RSS to display verses. Don't worry--you don't need to know the ins and outs of RSS to use the Verse of the Day, but you will need to get yourself a copy of a RSS parser before getting started.

You can download the Magpie RSS code at this site. Once you've downloaded the file, uncompress it using compression tool like 7-Zip or a similar program that can uncompress a tar.gz file.

Magpie consists of 4 files (rss_fetch.inc, rss_parser.inc, rss_cache.inc, and rss_utils.inc), and the directory extlib (which contains a modified version of the Snoopy HTTP client). Copy these 5 resources to a directory named 'magpierss' in the same directory as your PHP script.

2) Add the Verse of the Day code to your website

Copy the Verse of the Day code below and paste it into the HTML of your website:

<?php
  /**
   * Display Bible Gateway Verse of the Day from rss
   */

  /* include magpierss http://magpierss.sourceforge.net/ */
  include 'magpierss/rss_fetch.inc';

  /* version_id is the version to display. 31 is NIV.
    A complete listing of versions can be found here:
    http://www.biblegateway.com/usage/linking/versionslist/
  */
  $version_id = 31;
  $votd_url = "http://www.biblegateway.com/usage/votd/rss/votd.rdf?$version_id";

  $verse = @fetch_rss($votd_url);

  if (is_array($verse)) {
    $verse = $verse->items[0];

    $verse_text = trim($verse['content']['encoded']);
    $verse_ref = $verse['title'];
    $verse_link = $verse['guid'];
  }
  else {
    /* An error has occured. Handle it here. */
  }
?>

Important: once you've pasted the Verse of the Day code into your website, you'll need to tell it where to find the fetch_rss.inc file you dealt with in step #1 above. This means you need to change the quoted section of this line of code:

include 'magpierss/rss_fetch.inc';


...to accurately point at the rss_fetch.inc file on your website. The path can be relative or absolute.

3) Customize the Verse of the Day

Now you're ready to customize how you want the Verse of the Day to look on your site. Do you want the verse to be from the New International Version, or maybe the New King James Version? You can set this option by adjusting the $version_id parameter in the Verse of the Day code. Set the $version_id variable to version you want. Vesion numbers can be found in this page.

4) Put it online

Once you're done making your adjustments to the file, you're done! Put your webpage online and check to see if everything is working properly; if everything went as planned, you should now have the Verse of the Day displayed on your site. You can go back to the HTML to make any other adjustments or changes needed to make the Verse display just the way you want it.

Important note: while you are free to customize the Verse of the Day to display the way you'd like, you are required to leave the "Powered by BibleGateway.com" text in place.