Below, you’ll find a detailed guide on how to add the Stock Market Ticker Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Stock Market Ticker Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Stock Market Ticker Plugin and the shortcodes it provides:
"Stock Market Ticker is a dynamic WordPress plugin that provides real-time updates on stock market trends. Ideal for finance blogs and websites, it transforms your site into a financial information hub."
- [stock-market-ticker]
Stock Market Ticker [stock-market-ticker] Shortcode
The Stock Market Ticker shortcode enables the display of real-time stock market data on your WordPress site. It uses the Stockdio API to fetch the data. This shortcode allows customization for symbols, stock exchange, layout type, culture, speed, font, and color themes. It also supports settings for scroll, width, height, and transparency.
Shortcode: [stock-market-ticker]
Parameters
Here is a list of all possible stock-market-ticker shortcode parameters and attributes:
symbols
– Specifies the stock symbols to be displayed in the ticker.stockexchange
– Defines the stock exchange for the ticker symbols.exchange
– Another parameter to define the stock exchange.scroll
– Controls the scrolling feature of the ticker.layouttype
– Determines the layout type of the ticker.culture
– Sets the culture for the ticker, affecting language and formatting.loaddatawhenvisible
– Controls when the ticker data is loaded.speed
– Adjusts the scrolling speed of the ticker.width
– Sets the width of the ticker.height
– Sets the height of the ticker.font
– Specifies the font used in the ticker.transparentbackground
– Determines whether the ticker background is transparent.backgroundcolor
– Sets the background color of the ticker.labelscolor
– Defines the color of the labels in the ticker.positivecolor
– Sets the color for positive changes in the ticker.negativecolor
– Sets the color for negative changes in the ticker.motif
– Specifies the motif for the ticker.palette
– Defines the color palette used in the ticker.
Examples and Usage
Basic example – Display a stock market ticker with default settings.
[stock-market-ticker /]
Advanced examples
Display a stock market ticker for specific symbols with a custom speed and layout type.
[stock-market-ticker symbols="AAPL;MSFT;GOOG" speed="fast" layouttype="compact" /]
Display a stock market ticker with a custom font, background color, and labels color.
[stock-market-ticker font="Arial" backgroundcolor="#FFFFFF" labelscolor="#000000" /]
Display a stock market ticker for a specific stock exchange, with custom positive and negative colors.
[stock-market-ticker stockexchange="NASDAQ" positivecolor="#00FF00" negativecolor="#FF0000" /]
Display a stock market ticker with a custom width, height, and transparent background.
[stock-market-ticker width="500px" height="50px" transparentbackground="true" /]
Display a stock market ticker with a specific culture setting and data loading behavior.
[stock-market-ticker culture="en-US" loaddatawhenvisible="true" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [stock-market-ticker]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'stock-market-ticker', 'stockdio_ticker_func' );
Shortcode PHP function:
function stockdio_ticker_func( $atts ) {
//make array of arguments and give these arguments to the shortcode
$a = shortcode_atts( array(
'symbols' => '',
'stockexchange' => '',
'exchange' => '',
'scroll' => '',
'layouttype'=>'',
'culture' => 'normal',
'loaddatawhenvisible'=>'',
'speed' => '',
'width' => '',
'height' => '',
'font' => '',
'transparentbackground' => '',
'backgroundcolor' => '',
'labelscolor' => '',
'positivecolor' => '',
'negativecolor' => '',
'motif' => '',
'palette' => '',
), $atts );
//create variables from arguments array
extract($a);
if (!empty($exchange) && empty($stockexchange)){
$stockexchange = $exchange;
}
//assign settings values to $stockdio_ticker_options
$stockdio_ticker_options = get_option( 'stockdio_ticker_options' );
$api_key = '';
if (isset($stockdio_ticker_options['api_key']))
$api_key = $stockdio_ticker_options['api_key'];
$extraSettings = '';
$defaultSymbols = 'AAPL;MSFT;GOOG;HPQ;ORCL;FB;CSCO';
stockdio_ticker_get_param_value('symbols', $symbols, 'string', $extraSettings, $stockdio_ticker_options, $defaultSymbols);
if (strpos($extraSettings, $defaultSymbols) === false)
stockdio_ticker_get_param_value('stockExchange', $stockexchange, 'string' , $extraSettings, $stockdio_ticker_options, '');
stockdio_ticker_get_param_value('scroll', $scroll, 'string' , $extraSettings, $stockdio_ticker_options, '');
stockdio_ticker_get_param_value('layoutType', $layouttype, 'string' , $extraSettings, $stockdio_ticker_options, '');
stockdio_ticker_get_param_value('culture', $culture, 'string' , $extraSettings, $stockdio_ticker_options, '');
stockdio_ticker_get_param_value('speed', $speed, 'string' , $extraSettings, $stockdio_ticker_options, 'normal');
stockdio_ticker_get_param_value('font', $font, 'string' , $extraSettings, $stockdio_ticker_options, '');
stockdio_ticker_get_param_value('labelsColor', $labelscolor, 'color' , $extraSettings, $stockdio_ticker_options, '');
stockdio_ticker_get_param_value('positiveColor', $positivecolor, 'color' , $extraSettings, $stockdio_ticker_options, '');
stockdio_ticker_get_param_value('negativeColor', $negativecolor, 'color' , $extraSettings, $stockdio_ticker_options, '');
stockdio_ticker_get_param_value('palette', $palette, 'string' , $extraSettings, $stockdio_ticker_options, '');
stockdio_ticker_get_param_value('motif', $motif, 'string' , $extraSettings, $stockdio_ticker_options, '');
$showChart = true;
//$default_includeChart ='';
//$initCheck = $stockdio_ticker_options['booleanIniCheck'] == '1';
//if (isset($stockdio_ticker_options['default_includeImage']))
// $default_includeImage = $stockdio_ticker_options['default_includeImage'];
//if (empty($includeimage))
// $includeimage=$default_includeImage;
$default_transparentBackground = "true";
if (!array_key_exists('default_transparentBackground',$stockdio_ticker_options) || (array_key_exists('default_transparentBackground',$stockdio_ticker_options) && $stockdio_ticker_options['default_transparentBackground'] == 0) )
$default_transparentBackground = "false";
if (empty($transparentbackground))
$transparentbackground=$default_transparentBackground;
if ($transparentbackground == "1" || $transparentbackground == "true") {
$extraSettings .="&backgroundColor=transparent";
}
else{
stockdio_ticker_get_param_value('backgroundColor', $backgroundcolor, 'color' , $extraSettings, $stockdio_ticker_options, '');
}
$link = 'https://api.stockdio.com/visualization/financial/charts/v1/ticker';
$default_width = '';
if (isset($stockdio_ticker_options['default_width']))
$default_width = $stockdio_ticker_options['default_width'];
if (empty($width))
$width =$default_width;
if (empty($width))
$width ='100%';
if (strpos($width, 'px') !== FALSE && strpos($width, '%') !== FALSE)
$width =$width.'px';
$extraSettings .= '&width='.urlencode('100%');
$iframe_id= str_replace("{","",strtolower(getTickerGUID()));
$iframe_id= str_replace("}","",$iframe_id);
$extraSettings .= '&onload='.$iframe_id;
$default_height = '';
if (isset($stockdio_ticker_options['default_height']))
$default_height = $stockdio_ticker_options['default_height'];
$iframeHeight = '';
if (empty($height))
$height =$default_height;
if (strpos($height, 'px') !== FALSE && strpos($height, '%') !== FALSE)
$height =$height.'px';
if (!empty($height)){
$extraSettings .= '&height='.urlencode($height);
$iframeHeight=' height="'.$height.'" ';
}
//make main html output
$default_loadDataWhenVisible = "true";
if (!array_key_exists('default_loadDataWhenVisible',$stockdio_ticker_options) || (array_key_exists('default_loadDataWhenVisible',$stockdio_ticker_options) && $stockdio_ticker_options['default_loadDataWhenVisible'] == 0) )
$default_loadDataWhenVisible = "false";
if (empty($loaddatawhenvisible))
$loaddatawhenvisible=$default_loadDataWhenVisible;
$src = 'src';
if ($loaddatawhenvisible == "1" || $loaddatawhenvisible == "true")
$src = 'iframesrc';
$output = '<iframe referrerpolicy="no-referrer-when-downgrade" id="'.$iframe_id.'" frameBorder="0" class="stockdio_ticker" scrolling="no" width="'.$width.'" '.$iframeHeight.' '.$src.'="'.$link.'?app-key='.$api_key.'&wp=1&addVolume=false'.$extraSettings.'"></iframe>';
//$output = '<span> $labelscolor: '. $labelscolor.' </span><iframe referrerpolicy="no-referrer-when-downgrade" id="'.$iframe_id.'" frameBorder="0" class="stockdio_ticker" scrolling="no" width="'.$width.'" '.$iframeHeight.' '.$src.'="'.$link.'?app-key='.$api_key.'&wp=1&addVolume=false&showUserMenu=false'.$extraSettings.'"></iframe>';
//return completed string
return $output;
}
Code file location:
stock-market-ticker/stock-market-ticker/stockdio_ticker_stockdioplugin.php
Conclusion
Now that you’ve learned how to embed the Stock Market Ticker Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply