wordpress vue_Vue和WordPress —从您的WordPress网站轻松检索博客文章

本文介绍了如何使用Vue.js从WordPress网站上便捷地检索和显示博客文章,结合实际案例,帮助开发者理解这两个平台的集成过程。
摘要由CSDN通过智能技术生成

wordpress vue

您的Vue和WordPress权威指南-第1部分 (Your Definitive Guide to Vue and WordPress — Part 1)

I am currently working on a freelance project that involves retrieving posts from a WordPress site and displaying them on a custom dashboard and an Android and iOS app. It has been a fun project so far and I thought I would share my experience working with the WordPress REST API and Vue. I’ll publish another article about the mobile app experience soon! I will also go over how to create new posts from a Vue app in a separate article.

我目前正在从事一个自由职业项目,该项目涉及从WordPress网站检索帖子并将其显示在自定义仪表板以及Android和iOS应用上。 到目前为止,这是一个有趣的项目,我想分享一下使用WordPress REST API和Vue的经验。 我将很快发布另一篇有关移动应用程序体验的文章! 我还将在另一篇文章中介绍如何从Vue应用创建新帖子。

如何使用WordPress Rest API检索帖子 (How to Retrieve Posts Using the WordPress Rest API)

To read data from the WordPress site, we will use an API already built into the WordPress site. The WordPress REST API provides an interface for applications to interact with your WordPress site by sending and receiving data as JSON (JavaScript Object Notation) objects. To successfully use this API, there are a few things to know.

要从WordPress网站读取数据,我们将使用WordPress网站中已内置的API。 WordPress REST API通过发送和接收作为JSON (JavaScript对象符号)对象的数据为应用程序与WordPress站点进行交互提供了接口。 要成功使用此API,需要了解以下几点。

我的API端点在哪里? (Where are my API Endpoints?y)

For a full list of endpoints for the WordPress REST API, check out the link below.

有关WordPress REST API端点的完整列表,请查看下面的链接。

REST API Developer Endpoint Reference

REST API开发人员端点参考

To read data from your WordPress site, you must know where to request it. To get posts from your WordPress site, you would use the following endpoint.

要从WordPress网站读取数据,您必须知道在何处请求数据。 要从您的WordPress网站获取帖子,您可以使用以下端点。

YourWebSite/wp-json/wp/v2/posts

YourWebSite / wp-json / wp / v2 / posts

For this article, we will use the sample site provided in the WordPress Rest API documentation.

对于本文,我们将使用WordPress Rest API文档中提供的示例站点。

https://demo.wp-api.org

https://demo.wp-api.org

To retrieve posts from the site linked above, your endpoint would look like the example below:

要从上面链接的站点检索帖子,您的端点应类似于以下示例:

https://demo.wp-api.org/wp-json/wp/v2/posts

https://demo.wp-api.org/wp-json/wp/v2/posts

The above endpoint returns a JSON object representing posts from the demo WordPress site. If you click on the link, you w

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值