Welcome to Dagon Design. In addition to free scripts, WordPress plugins, and articles, we offer a variety of services including custom theme design, plugin creation, and PHP scripting. Contact me for more information.

Version 1.0   Updated Sunday, March 22nd, 2009 at 8:20pm

Stock Quotes Plugin for WordPress

This WordPress plugin allows you to easily display stock quotes on your website. The output of the plugin is designed to be minimal – the stock symbol, last price, and change amount are shown. You can configure the output in the options page for the plugin. The data is retrieved from Yahoo finance.

Download

  If you have found this page useful, please consider donating. Thanks!

Instructions

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory
  • Enable the plugin
  • Configure the plugin options (under DDStockQuotes)

Demo

MSFT 23.865 [-0.035]
GOOG 462.815 [+2.48]

Change Log

  • 03-22-09 Version 1.0 – First release

Usage

There are two ways this plugin can be used:

In a post or page:
[stock SYMBOL]

From a template file:
<?php echo ddsq_get_quote('SYMBOL'); ?>

* where SYMBOL is the stock symbol you want to use

Important note regarding symbols

For most stocks, you can simply use the standard symbol, but for some cases (such as indexes) you will have to use the proper tags from Yahoo Finance. First, use this URL to search for your stock/index/etc..

http://finance.yahoo.com/

Then when the results are shown, look at the URL. For example, searching for the Dow Jones Industrial Average. From the ’s’ parameter in the URL, and the symbol shown next to the name, you will see that it uses ^DJI. For the S&P 500, the tag is ^GSPC.

Options

Here are the options available in this plugin’s options page in the WordPress admin panel.

Output Format

This is the format of the plugin output. You can use any HTML you want, using the placeholders for the values: %NAME% %LAST% %CHANGE%

Example: <strong>%NAME%</strong> %LAST% [<strong>%CHANGE%</strong>]

Up Color

Color to use for price change when up (leave blank to disable)

Down Color

Color to use for price change when down (leave blank to disable)

Non-WordPress usage of the code

If you would like to use this script in your own PHP code, outside of WordPress, it is easy to do. All you need is the ddsq_get_quote function from the plugin, replacing the three lines at the start of the function (which pull the option settings from WordPress), with the actual option strings. Example:

$quote_format = '<strong>%NAME%</strong> %LAST% [<strong>%CHANGE%</strong>]';
$up_color = '00BB00';
$down_color = 'FF0000';

Pages: [2] 1 » Show All

  1. We supply all kinds of moncler boots,moncler bags,moncler coats,moncler jackets,moncler T-shirt,moncler vest and so on.We have got a good reputation pf our products with top quality and good price.We sincerely look forward to futher cooperation with you for mutual benefits.We are sure that you will find working with us is a pleasant, time-saving and profitable experience. Please feel free to contact us if you have any questions.Our website is http://www.newlyapparel.com.

  2. Thanks for the plugin.

  3. Hey,

    First thanks for script, very nice and works with wordpress beatifully. Secondly, i have an error on the site when i put in symbols. I followed the direction, but maybe i missed something or this is not compatible with 2.9.2

    Here is the site Indie Stocks – Stocks under $5

    Thanks for your help!

Pages: [2] 1 » Show All

Leave a Comment

Before you comment: If you are having an issue with a script, please make sure you have read the entire article. Also, please read through the comments because most common issues have already been discussed many times. Thanks.


Be sure to wrap all code in <code></code> tags.