Below, you’ll find a detailed guide on how to add the Stock Market Overview 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 Overview Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Stock Market Overview Plugin and the shortcodes it provides:
"Stock Market Overview is a dynamic WordPress plugin designed to keep you updated with real-time stock market data. It's perfect for finance bloggers and investors."
- [stock-market-overview]
Stock Market Overview [stock-market-overview] Shortcode
The ‘stock-market-overview’ shortcode is designed to display a comprehensive overview of the stock market on a WordPress site. It fetches real-time data from the Stockdio API and presents it in a customizable format. The user can specify parameters like ‘title’, ‘stockexchange’, ‘includeequities’ etc. to tailor the displayed information. The shortcode also supports color customization for various elements and includes chart display options for a visual representation of the market data.
Shortcode: [stock-market-overview]
Parameters
Here is a list of all possible stock-market-overview shortcode parameters and attributes:
title
– sets the title of the stock market overview.stockexchange
– specifies the stock exchange to display.exchange
– an alternate parameter for specifying the stock exchange.includeequities
– decides whether to include equities in the overview.includeindices
– decides whether to include indices in the overview.includecommodities
– decides whether to include commodities in the overview.includecurrencies
– decides whether to include currencies in the overview.equities
– specifies the equities to include in the overview.indices
– specifies the indices to include in the overview.commodities
– specifies the commodities to include in the overview.currencies
– specifies the currencies to include in the overview.culture
– sets the cultural context for the overview.loaddatawhenvisible
– loads data when the overview is visible.width
– sets the width of the overview.height
– sets the height of the overview.font
– sets the font for the overview.motif
– sets the motif for the overview.palette
– sets the color palette for the overview.logomaxheight
– sets the maximum height for the logo.logomaxwidth
– sets the maximum width for the logo.includelogo
– decides whether to include the logo in the overview.includeequitiessymbol
– decides whether to include equity symbols.includeequitiesname
– decides whether to include equity names.includeindicesymbol
– decides whether to include index symbols.includeincidesname
– decides whether to include index names.includecommoditiessymbol
– decides whether to include commodity symbols.includecommoditiesname
– decides whether to include commodity names.includecurrenciessymbol
– decides whether to include currency symbols.includecurrenciesname
– decides whether to include currency names.includeprice
– decides whether to include price in the overview.includechange
– decides whether to include change in the overview.includepercentchange
– decides whether to include percent change.includetrend
– decides whether to include trend in the overview.includevolume
– decides whether to include volume in the overview.showheader
– decides whether to show the header.includechart
– decides whether to include a chart in the overview.chartheight
– sets the height of the chart.displayprices
– decides whether to display prices in the overview.days
– sets the number of days for the overview.allowperiodchange
– allows period change in the overview.intraday
– sets the intraday period for the overview.allowsort
– allows sorting in the overview.bordercolor
– sets the border color of the overview.backgroundcolor
– sets the background color of the overview.captioncolor
– sets the caption color of the overview.titlecolor
– sets the title color of the overview.pricecolor
– sets the price color in the overview.volumecolor
– sets the volume color in the overview.Examples and Usage
Basic example – Display a Stock Market Overview with default options
[stock-market-overview]
Advanced examples
Display a Stock Market Overview with specified title and stock exchange
[stock-market-overview title="My Stock Overview" stockexchange="NASDAQ"]
Display a Stock Market Overview with specified commodities and currencies, and change the culture to French
[stock-market-overview includecommodities="Gold,Silver" includecurrencies="USD,EUR" culture="fr-FR"]
Display a Stock Market Overview with specified equities and indices, and adjust the width and height
[stock-market-overview equities="AAPL,GOOGL" indices="^DJI,^IXIC" width="500px" height="300px"]
Display a Stock Market Overview with specified font and motif, and adjust the colors
[stock-market-overview font="Arial" motif="Financial" bordercolor="#000000" backgroundcolor="#ffffff" titlecolor="#0000ff"]
PHP Function Code
In case you have difficulties debugging what causing issues with
[stock-market-overview]
shortcode, check below the related PHP functions code.Shortcode line:
add_shortcode( 'stock-market-overview', 'stockdio_market_overview_func' );
Shortcode PHP function:
function stockdio_market_overview_func( $atts ) { //make array of arguments and give these arguments to the shortcode $a = shortcode_atts( array( 'title' => '', 'stockexchange' => '', 'exchange' => '', 'includeequities' => '', 'includeindices' => '', 'includecommodities' => '', 'includecurrencies' => '', 'equities' => '', 'indices' => '', 'commodities' => '', 'currencies' => '', 'culture' => '', 'loaddatawhenvisible' => '', 'width' => '', 'height' => '', 'font' => '', 'motif' => '', 'palette' => '', 'logomaxheight' => '', 'logomaxwidth' => '', 'includelogo' => '', 'includeequitiessymbol' => '', 'includeequitiesname' => '', 'includeindicesymbol' => '', 'includeincidesname' => '', 'includecommoditiessymbol' => '', 'includecommoditiesname' => '', 'includecurrenciessymbol' => '', 'includecurrenciesname' => '', 'includeprice' => '', 'includechange' => '', 'includepercentchange' => '', 'includetrend' => '', 'includevolume' => '', 'showheader' => '', 'includechart' => '', 'chartheight' => '', 'displayprices' => '', 'days' => '', 'allowperiodchange' => '', 'intraday' => '', 'allowsort' =>'', 'bordercolor' => '', 'backgroundcolor' => '', 'captioncolor' => '', 'titlecolor' => '', 'pricecolor' => '', 'volumecolor' => '', 'labelscolor' => '', 'interlacedcolor' => '', 'axeslinescolor' => '', 'positivecolor' => '', 'positivetextcolor' => '', 'negativecolor' => '', 'negativetextcolor' => '', 'periodscolor' => '', 'periodsbackgroundcolor' => '', 'headercolor' => '', 'headerbackgroundcolor' => '', 'tooltipscolor' => '', 'tooltipstextcolor' => '', ), $atts ); //create variables from arguments array extract($a); if (!empty($exchange) && empty($stockexchange)){ $stockexchange = $exchange; } //assign settings values to $stockdio_market_overview_options $stockdio_market_overview_options = get_option( 'stockdio_market_overview_options' ); $api_key = ''; if (isset($stockdio_market_overview_options['api_key'])) $api_key = $stockdio_market_overview_options['api_key']; $extraSettings = ''; stockdio_market_overview_get_param_value('culture', $culture, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('font', $font, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('palette', $palette, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('motif', $motif, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('title', $title, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('stockExchange', $stockexchange, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('equities', $equities, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('indices', $indices, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('commodities', $commodities, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('currencies', $currencies, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('logoMaxHeight', $logomaxheight, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('logoMaxWidth', $logomaxwidth, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('includeEquities', $includeequities, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includeIndices', $includeindices, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includeCommodities', $includecommodities, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includeCurrencies', $includecurrencies, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includeLogo', $includelogo, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includeEquitiesSymbol', $includeequitiessymbol, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includeEquitiesName', $includeequitiesname, 'bool' , $extraSettings, $stockdio_market_overview_options, '0'); stockdio_market_overview_get_param_value('includeIndiceSymbol', $includeindicesymbol, 'bool' , $extraSettings, $stockdio_market_overview_options, '0'); stockdio_market_overview_get_param_value('includeIncidesName', $includeincidesname, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includeCommoditiesSymbol', $includecommoditiessymbol, 'bool' , $extraSettings, $stockdio_market_overview_options, '0'); stockdio_market_overview_get_param_value('includeCommoditiesName', $includecommoditiesname, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includeCurrenciesSymbol', $includecurrenciessymbol, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includeCurrenciesName', $includecurrenciesname, 'bool' , $extraSettings, $stockdio_market_overview_options, '0'); stockdio_market_overview_get_param_value('allowSort', $allowsort, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includePrice', $includeprice, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includeChange', $includechange, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includePercentChange', $includepercentchange, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includeTrend', $includetrend, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); stockdio_market_overview_get_param_value('includeVolume', $includevolume, 'bool' , $extraSettings, $stockdio_market_overview_options, '0'); stockdio_market_overview_get_param_value('showHeader', $showheader, 'bool' , $extraSettings, $stockdio_market_overview_options, '0'); //colors: stockdio_market_overview_get_param_value('borderColor', $bordercolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('backgroundColor', $backgroundcolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('captionColor', $captioncolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('titleColor', $titlecolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('priceColor', $pricecolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('axesLinesColor', $axeslinescolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('positiveColor', $positivecolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('positiveTextColor', $positivetextcolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('negativeColor', $negativecolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('negativeTextColor', $negativetextcolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('periodsColor', $periodscolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('periodsBackgroundColor', $periodsbackgroundcolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('tooltipsColor', $tooltipscolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('tooltipsTextColor', $tooltipstextcolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); //stockdio_market_overview_get_param_value('volumeColor', $volumecolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('labelsColor', $labelscolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('interlacedColor', $interlacedcolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('headerColor', $headercolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('headerBackgroundColor', $headerbackgroundcolor, 'color' , $extraSettings, $stockdio_market_overview_options, ''); $showChart = true; $default_includeChart =''; $initCheck = array_key_exists('booleanIniCheck',$stockdio_market_overview_options)? $stockdio_market_overview_options['booleanIniCheck'] == '1' : false; if (isset($stockdio_market_overview_options['default_includeChart'])) $default_includeChart = $stockdio_market_overview_options['default_includeChart']; $default_intraday = "true"; if ($stockdio_market_overview_options['default_intraday'] == 0 && $stockdio_market_overview_options['intradayCheck']!= "") $default_intraday = "false"; if (empty($includechart)) $includechart=$default_includeChart; $link = 'https://api.stockdio.com/visualization/financial/charts/v1/marketoverview'; //return "<strong>".$default_includeChart."</strong>"; if ($includechart=="1" ||$includechart=="true" || $title != "" || (isset($default_title) && $default_title != "")) $showBorderAndTitle = '&showBorderAndTitle=true'; else $showBorderAndTitle = '&showBorderAndTitle=false'; $extraSettings .= $showBorderAndTitle; if ($includechart=="1" ||$includechart=="true"){ $link = 'https://api.stockdio.com/visualization/financial/charts/v1/marketoverviewchart'; stockdio_market_overview_get_param_value('displayPrices', $showheader, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('days', $days, 'string' , $extraSettings, $stockdio_market_overview_options, ''); stockdio_market_overview_get_param_value('allowPeriodChange', $allowperiodchange, 'bool' , $extraSettings, $stockdio_market_overview_options, '1'); $default_chartHeight = ''; if (isset($stockdio_market_overview_options['default_chartHeight'])) $default_chartHeight = $stockdio_market_overview_options['default_chartHeight']; if (empty($chartheight)) $chartheight =$default_chartHeight; if (strpos($chartheight, 'px') !== FALSE && strpos($chartheight, '%') !== FALSE) $chartheight =$chartheight.'px'; if (empty($chartheight)) $chartheight='200px'; $extraSettings .= '&chartHeight='.$chartheight; } $default_width = ''; if (isset($stockdio_market_overview_options['default_width'])) $default_width = $stockdio_market_overview_options['default_width']; $default_height = ''; if (isset($stockdio_market_overview_options['default_height'])) $default_height = $stockdio_market_overview_options['default_height']; 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%'); $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.'" '; } if (empty($intraday)) $intraday=$default_intraday; if ($intraday == "1") $intraday = 'true'; if ($intraday == "0") $intraday = 'false'; $extraSettings .= '&intraday='.$intraday; $iframe_id= str_replace("{","",strtolower(getSMOGUID())); $iframe_id= str_replace("}","",$iframe_id); $extraSettings .= '&onload='.$iframe_id; //make main html output $default_loadDataWhenVisible = "true"; if (!array_key_exists('default_loadDataWhenVisible',$stockdio_market_overview_options) || (array_key_exists('default_loadDataWhenVisible',$stockdio_market_overview_options) && $stockdio_market_overview_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_market_overview" 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-overview/stock-market-overview/stockdio_market_overview_stockdioplugin.php
Conclusion
Now that you’ve learned how to embed the Stock Market Overview 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