简介 WordPress v4.4以后,已经内置了WP REST API。 接口文档:https://developer.wordpress.org/rest-api/ The WordPress REST API provides an interface for applications to interact with your WordPress site by sending and r […]
1,数据库相关表 WordPress 文章表中是没有文章点击次数这个字段的,所以把文章点击次数,保存在表 wp_postmeta 中。 2, 通用函数 /** * 设置文章浏览次数 */ function setPostViews($postID) { $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_k […]
什么是 WordPress 插件 ? 插件( Plugins )是如何与 WordPress 交互的 WordPress 为插件提供了多种丰富的 APIs。每一种 API( 应用程序接口 )使插件和 WordPress 以不同的方式交互。下面是 WordPress 提供的主要 APIs 以及他们的功能列表: 插件: 给插件提供一系列的钩子( hooks )来使用 WordPress 的相关部分。W […]
WordPress 一共有以下12个表,默认表前缀是 “wp_” wp_commentmeta 存储评论的元数据 meta_id:自增唯一ID comment_id:对应评论ID meta_key:键名 meta_value:键值 wp_comments 存储评论 comment_ID:自增唯一ID comment_post_ID:对应文章ID comment_author […]
WordPress 循环读取文章数据的方法一般使用 query_posts(),但是 query_posts() 这个函数有一些缺点,可能会干扰那些用到的Loop(循环)的插件。可能使一些 WordPress 条件标签失效。这时候最好的选择就是使用 WP_Query 类了。 用法: 参数详解:
WordPress 自带的 RESTful API 内置的身份验证方法是 Cookie Authentication ,登录仪表板时,会生成cookie。为了防止CSRF,需要在请求的地址后面,加上一个 nonce 参数“_wpnonce”。 CSRF请参考:https://javascript.net.cn/article?id=683 nonce生成,参考:https://verytheme. […]
1, bloginfo(‘template_url’) http://localhost/wordpress/wp-content/themes/mytheme 2, bloginfo(‘template_directory’) http://localhost/wordpress/wp-content/themes/mytheme 3, get_t […]
一,添加路由 add_action( 'rest_api_init', function () { register_rest_route( 'rangtuo/v1', '/author/(?P<id>\d+)', array( 'methods' => 'GET', 'callback' => 'test_callback', )); }); function test_ […]
图片列表
热门文章
-
WordPress 添加自定义接口2年前 (2023-06-28)
-
WordPress 文章置顶循环2年前 (2023-07-04)
-
Mirage 主题1年前 (2024-07-28)
-
Misa 主题6个月前 (05-04)