WordPress 帖子内容可以是外部数据吗(不是来自数据库) [英] Can WordPress post content be external data (not from the database)
问题描述
我试图根据从外部 API (Amazon) 返回的一些数据来显示页面.然后,这些数据被格式化,必须显示在页面上,根据 URL 查询动态创建.我已经可以用短代码来做到这一点,但这必须来自查询.
I am trying to display a page based on some data returned from an external API (Amazon). This data is formatted then, has to be displayed on a page, created on the fly, based on URL querys. I can already do this with shortcodes but this has to be from the query.
我在 codex 中看到了关于将自定义 query_posts 从数据库返回到循环中的各种信息.但是,我找不到让外部数据显示在页面上的信息.
I see all kinds of info in the codex on returning custom query_posts into the loop from the database. However, I cannot find info getting external data to appear on a page.
这在 WordPress 中可行吗?(一切皆有可能,对吗?)请指点我一些功能、过滤器或教程.
Is this possible in WordPress? (anything is possible, right?) Just point me to some functions, filters or tutorials please.
推荐答案
如果我理解正确,您想动态检索数据并将其显示在 WordPress 页面中吗?
If I understand you correctly, you want to retrieve data dynamically and display it in a WordPress page?
有很多方法可以做到这一点,但这是一种选择:
There are many ways to do this, but here's one option:
- 创建页面模板
- 创建一个 WordPress 页面并使用在步骤 1 中创建的页面模板.
- 编辑页面模板以调用外部API并显示数据
我猜您一直在尝试从页面或帖子的内容"中找到一种方法来执行此操作,但最简单的方法是将代码放入自定义页面模板中.
I'm guessing you've been trying to find a way to do this from the "content" of a page or post, but the easiest way is to put the code in a custom Page Template.
更新:如果您想以编程方式创建页面,这可能适合您:http://wordpress.org/support/topic/how-to-create-pages-programmatically?reply=5#post-1230619
UPDATE: If you want to programmatically create a page, this might work for you: http://wordpress.org/support/topic/how-to-create-pages-programmatically?replies=5#post-1230619
这篇关于WordPress 帖子内容可以是外部数据吗(不是来自数据库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!