本文介绍了在 WordPress 页面上显示来自 Google 电子表格的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了本网站上的教程 https://www.wp-tweaks.com/display-a-single-cell-from-google-sheets-wordpress/ 允许使用简单的短代码:

I have followed the tutorial on this website https://www.wp-tweaks.com/display-a-single-cell-from-google-sheets-wordpress/ which allows to dynamically display values from a Google spreadsheet on a WordPress page using a simple shortcode:

[get_sheet_value location="Cell Location"]

这个解决方案无缝地工作,直到一个页面包含数百个这样的短代码(我基本上需要页面的整个内容可以通过电子表格进行编辑).我开始通过 API 方法(基于 Google 指标)获得 100% 错误,并且内容不再正确显示.我意识到在每个页面加载后发送数百个读取请求并不理想,并且不可避免地会影响加载性能,而且 Google 也施加了配额限制.有没有办法绕过这个问题?例如,每天仅从 Google 电子表格中提取一次值.不幸的是,我没有太多的编码经验,但我对所有解决方案持开放态度.提前致谢!

This solution worked seamlessly until a single page contained hundreds of those shortcodes (I basically need the whole content of the page to be editable via the spreadsheet). I started getting 100% Errors by API method (based on the Google Metrics) and the content was not displayed properly anymore. I realize that sending hundreds of read requests after each page load is not ideal and will inevitably affect the load performance and that Google imposes quota limits too. Is there a way to bypass this issue? For example by pulling the values from the Google spreadsheet only once a day. Unfortunately, I don't have much coding experience but I'm open to all solutions.Thanks in advance!

推荐答案

您可以发布将工作表上传到网络并将其嵌入您的网站:

You could publish the sheet to the web and embed it to your website:

  1. 在您的工作表中,转到文件 >发布到网络
  2. 在出现的窗口中,点击嵌入.
  3. 点击发布.
  4. 复制文本框中的代码并将其粘贴到您的网站中.
  5. 要显示或隐藏电子表格的某些部分,请编辑您网站上的 HTML.

它看起来像这样(点击运行代码片段):

It would look like this (click on Run code snippet):

  <iframe src="https://docs.google.com/spreadsheets/d/e/2PACX-1vR3UbHTtAkR8TGNtXU3o4hzkVVhSwhnckMp7tQVCl1Fds3AnU5WoUJZxTfJBZgcpBP0VqTJ9n_ptk6J/pubhtml?gid=1223818634&amp;single=true&amp;widget=true&amp;headers=false"></iframe>

这篇关于在 WordPress 页面上显示来自 Google 电子表格的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 21:17