Love our work? if you want a custom project Contact on Whatsapp

How To Add News Ticker Banner To Your Blogger & Wordpress Website Using Google Sheet Data

Do you want to add a news ticker on your site? Learn from our step by step guide on how to add a news ticker in WordPress with Ditty News Ticker.

🎉 Welcome to our website, where exploration meets inspiration! 🌟 Join us on our journey by subscribing to our YouTube channel, fueling our motivation to craft innovative projects. 🚀

Do you want to add a scrolling news ticker to your WordPress or Blogger site using google sheet database?

Television networks often use news tickers to highlight important stories. This is a great way to get the visitor’s attention, so you might want to add a news ticker to your website and then highlight special deals, popular posts, and other important content.

In this article, we will show you how to add a scrolling news ticker in WordPress.

Setup Video Guide Video

Steps to Install The Google Web App in your End.

What You Exactly Need 

A Google Account / Google Sheet File

Basic Knowledge of HTML , CSS , JAVASCRIPT 

Basic Knowledge of Google Appscript

Learn How to Deploy a New Web or Manage Web App in Appscript

Important!You need to have basic programming knowledge of HTML, CSS, and JavaScript to modify the code in this post. However, I will try my best to make the code readable and editable by non-programmers too.


Please Follow The Steps Here
How to Copy a Google Sheet

Click On Make a Copy To Copy the File In your Drive


Now Click on Extension and Choose a Appscript Option


Click on Deploy and Press on New Deployment


Now Here You Need to Select Anyone and Press on Deploy


After Deploy Allow Permission After Permission Given a URL Comes Which is Used to Access Your Web App and if You change in codes after deployment You need to apply Changes Need Deploy Again or Manage Deployments,

For Custom Projects!If You want a Custom Project For Your Business then Conatct Us :  +923224083545

Important!We always deliver what we promise to our clients. Quality over quantity is our motto! Our custom projects are priced reasonably and affordably for everyone. Join us and let's create something amazing together! 🎉🚀 Conatct Us :  +923224083545

Get Google Sheet

Contact us For Project

Join Whatsapp Community

For Custom Projects!If You want a Custom Project For Your Business then Conatct Us :  +923224083545 . 

Code.js
    function doPost(e) {
  var sheet = SpreadsheetApp.openById('/// YOUR GOOGLE SHEET ID HERE /////').getSheetByName('// YOUR SHEET NAME ///'); 
  var data = sheet.getRange('YOUR COLUMN FOR FETCH DATA').getValues(); 
  var news = [];
  
  for (var i = 0; i < data.length; i++) {
    if (data[i][0] !== '') {
      news.push(data[i][0]);
    }
  }
  
  // Return the news data as JSON
  return ContentService.createTextOutput(JSON.stringify(news))
    .setMimeType(ContentService.MimeType.JSON);
}

PASTE CODE IN STYLE TAG IN INDEX
   #marquee-cont {
  background: #f4f4f4;
  margin-top:10px;
}
#marquee-cont marquee {
  margin-top: 5px;
}
#marquee-news {
  
  background: #1174A8;
  padding: 5px;
}
#ticker-title{
  border:none;
  padding:5px 20px;
  background:#1174A8;
  color:white;
}
#ticker-title:focus{
  outline:none;
}


Index.html 
<header>
<div id="marquee-cont">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="50px" style="background:#1174A8;">
        <button id="ticker-title">LATEST NEWS:</button>
      </td>
      <td id="marquee">
        <marquee onmouseover="this.stop();" onmouseout="this.start();" id="scroll"></marquee>
      </td>
    </tr>
  </table>
</div>
</header>
<style>
  #marquee-cont {
  background: #f4f4f4;
  margin-top:10px;
}
#marquee-cont marquee {
  margin-top: 5px;
}
#marquee-news {
 
  background: #1174A8;
  padding: 5px;
}
#ticker-title{
  border:none;
  padding:5px 20px;
  background:#1174A8;
  color:white;
}
#ticker-title:focus{
  outline:none;
}
</style>
<script>
  // Function to fetch data from Google Apps Script
  function fetchData() {
    fetch('// YOUR SCRIPT ID //', {
      method: 'POST'
    })
    .then(response => response.json())
    .then(news => {
      let tickerText = '';
      const logo = "<img src='/// LOGO PNG URL ///' width='25px' style='margin:0 8px'/>";
     
      // Loop through the news data and construct ticker text
      news.forEach((item, index) => {
        tickerText += item;
        if (index !== news.length - 1) {
          tickerText += logo;
        }
      });

      document.getElementById("scroll").innerHTML = tickerText;
    })
    .catch(error => console.error('Error fetching data:', error));
  }

  // Call fetchData function when the page loads
  fetchData();
</script>

Terms of Use

If you want to use this Code in your posts, please don't remove the attributes from the codes, it will not be visible on your website.

If you want to rewrite an article on this Codebox by using these codes, you must add a Reference with visible and clickable link redirecting to our website: https://www.rameezimdad.blogspot.com. If you rewrite without Reference, Legal Actions will be taken.

Conclusion

This is all about to help uou to Automate Your Business. I hope you enjoy this article. Please do share this article. And if you are facing problem in any section or you have any question then ask us in comment box. Thank you!

Post a Comment

Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.