I'm trying to integrate Tradingview charts to my wordpress site. I will store stock name in my database. Suppose someone searches for AAPL, the url should have AAPL as the stock name and accordingly, tradingview should load AAPL chart on my website. So basically if I'm storing stock_name in my database and user clicks on AAPL, url should return something like this:


Trading embed code is like:

<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container">
  <div id="tradingview_1f858"></div>
  <div class="tradingview-widget-copyright"><a href="https://in.tradingview.com/symbols/**stock_name**/" rel="noopener" target="_blank"><span class="blue-text">AAPL Chart</span></a> by TradingView</div>
  <script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
  <script type="text/javascript">
  new TradingView.widget(
  "width": 980,
  "height": 610,
  "symbol": "**stock_name**",
  "interval": "D",
  "timezone": "Etc/UTC",
  "theme": "light",
  "style": "1",
  "locale": "in",
  "toolbar_bg": "#f1f3f6",
  "enable_publishing": false,
  "allow_symbol_change": true,
  "container_id": "tradingview_1f858"
<!-- TradingView Widget END -->

So I wish to dynamically pass stock_name both in URL as well as in the embed code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.