文章來為各位介紹一個簡單的WordPress使用Node.js 重寫的例子,希望這個例子可以幫助到各位朋友.
要 WordPress 4.3 完全拒絕 PHP 還是不可能的,但是開發者計劃重寫一些基本的核心類,包括 WP_Query 、WP_Erro、和 WP_Object_Cache.
值得注意的是,發給 WordPress 數據庫的請求不僅可以在服務器端執行,也可以在客戶端用 JSON REST API 執行,此功能在 4.3 版本上實現,代碼可能是這樣:
- var query = new wp.Query ();
- query.setQuery ({
- post_type: 'post',
- post_status: 'publish',
- posts_per_page: 5
- }); //Vevb.com
- _.each (query.getPosts (), function (post) {
- console.log (post.title);
- console.log (post.content);
- console.log (post.author);
- });
新聞熱點
疑難解答
圖片精選