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.
- Latest Release (For WordPress 2.0 through 2.8+)
- 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)
MSFT 44.87 [-0.135]
GOOG 571.00 [-6.86]
- 03-22-09 Version 1.0 – First release
There are two ways this plugin can be used:
In a post or page:
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..
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.
Here are the options available in this plugin’s options page in the WordPress admin panel.
This is the format of the plugin output. You can use any HTML you want, using the placeholders for the values: %NAME% %LAST% %CHANGE%
<strong>%NAME%</strong> %LAST% [<strong>%CHANGE%</strong>]
Color to use for price change when up (leave blank to disable)
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';