Add a Bitcoin Marquee (Ticker) in WordPress with Shortcode

BitcoinAverage is a service providing the “BitcoinAverage Price Index”, a weighted average Bitcoin price across all reachable Bitcoin exchanges around the world. Currently over 40 exchanges are integrated, feeding nearly all available Bitcoin trading volume data. The BitcoinAverage Price Index is offered in over 150 currencies.

The website offers a free API with very few restrictions. Their API reference page says that “… there is no explicit restriction on how often you can call the API, however calling it more than once a minute makes no sense. Please be good”. While the Bitcoin price can vary wildly in the space of just a couple of minutes it still makes more sense with WordPress to cache it for longer periods to avoid making unnecessary and lengthy requests.

In this, our second article on various Bitcoin APIs, we’ll be adding a Bitcoin ticker to your WordPress website with shortcode. While there are numerous applications that might be considered given the comprehensive BtcoinAverage data (including historical CSV files) we’ll be making a simple request on this occasion, but we’ll certainly revisit the API in the future.

The HTML Marquee Tag

While there are a number of awesome ticker-type options made available with jQuery and native JavaScript – combined with some groovy CSS styling – we’re going to avoid that fancy-pants stuff and use nothing other than the HTML Marquee tag for the purpose of simplicity.

The marquee element provides a way for browsers to render text that moves across the page without having to resort to JavaScript techniques. The marquee is supported in virtually all browsers (despite the tag essentially being obsolete) although they all tend to provide their own subtle variations in the way its rendered, making the appearance alter slightly from one browser to another.

The marquee attributes are detailed in the section below on “Shortcode Attributes”. We’ll look at some styled tickers in the future.

The Result

A basic marquee ticker displaying currencies for Australia, USA, New Zealand, and China, is obtained via the shortcode of [bitcoinaverage]. While around 150 currencies are returned via the API, we’ve limited the returned data by way of a default value in the shortcode. The result:

฿ BTC Trading : AUD 24HR average $ Ask $3066.09 Bid $3045.39 Last $3061.16 Volume BTC 84279.29 Volume % 0.26 NZD 24HR average $ Ask $3233.31 Bid $3211.48 Last $3228.11 Volume BTC 84279.29 Volume % 0 USD 24HR average $ Ask $2280.71 Bid $2265.31 Last $2277.04 Volume BTC 84279.29 Volume % 58.26

The Shortcode Function

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

Shortcode Attributes


The API returns around 150 currencies – not all of which you’ll want to display in your marquee. If the currency attribute is left empty it will return them all.. but it’s likely that you will want to limit returned data relevant to your audience. If you want to display all data, you should do so on a dedicated page – not a marquee or ticker. In my case I return the currency in AUD, NZD, USD, and CHN (Chinese Yuan) using the shortcode of [bitcoinaverage currency="aud,$|nzd,$|usd,$|chn,¥"]. The format of each requested currency is the three letter country code followed by a comma, and then the HTML entity (or symbol) for the currency symbol. Each country/currency pair is separated by a p|pe character. Find currency HTML entity codes here.


Sets how the text is scrolled within the marquee. Possible values are scroll, slide and alternate. If no value is specified, the default value is scroll.


Sets the number of times the marquee will scroll. If no value is specified, the default value is 1, which means the marquee will scroll continuously. Since this support doesn’t seem to be globally recognised we use 100.


Sets the direction of the scrolling within the marquee. Possible values are left, right, up and down. If no value is specified, the default value is left.


Sets the height in pixels or percentage value.


Sets the horizontal margin.


Sets the amount of scrolling at each interval in pixels. The default value is 6.


Sets the interval between each scroll movement in milliseconds. The default value is 85. Note that any value smaller than 60 is ignored and the value 60 is used instead, unless truespeed is specified.


Sets the width in pixels or percentage value.


The number of seconds the API data will be cached locally before a request for fresh information is made. Defaults to 900 (15 minutes).


The following pages serve as references for BitcoinAverage:

We’ll be providing additional articles on working with the BitcoinAverage API in the future. Be sure to subscribe to our lonely Facebook page for updates.

Download the Code

Download the shortcode function here .

Shortt URL for this post:

Leave a Reply

Your email address will not be published. Required fields are marked *