首页 > CMS建站 > Wordpress > 正文

WordPress使用Node.js 重写的例子

2020-06-10 12:53:51
字体:
来源:转载
供稿:网友

文章来为各位介绍一个简单的WordPress使用Node.js 重写的例子,希望这个例子可以帮助到各位朋友.

要 WordPress 4.3 完全拒绝 PHP 还是不可能的,但是开发者计划重写一些基本的核心类,包括 WP_Query 、WP_Erro、和 WP_Object_Cache.

值得注意的是,发给 WordPress 数据库的请求不仅可以在服务器端执行,也可以在客户端用 JSON REST API 执行,此功能在 4.3 版本上实现,代码可能是这样:

  1. var query = new wp.Query ();   
  2. query.setQuery ({   
  3.     post_type: 'post',   
  4.     post_status: 'publish',   
  5.     posts_per_page: 5   
  6. }); //Cuoxin.com 
  7.     
  8. _.each (query.getPosts (), function (post) {   
  9.     console.log (post.title);   
  10.     console.log (post.content);   
  11.     console.log (post.author);   
  12. });

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选