gpt4 book ai didi

WordPress API 按类别获取帖子

转载 作者:行者123 更新时间:2023-12-02 21:28:19 25 4
gpt4 key购买 nike

是否可以按类别获取所有帖子?

http://codex.wordpress.org/XML-RPC_WordPress_API/Posts

最佳答案

我最终通过使用可选的过滤器参数成功地实现了此功能。根据文档,这些是以下可接受的过滤器参数。

结构过滤器:可选。 字符串 post_type 字符串 post_status 整数 整数偏移量 字符串排序依据 字符串顺序

出于好奇,我通过将以下内容添加到 getposts 方法下的 class-wp-xmlrpc-server.php 来发送“类别”过滤器

if(isset($filter['category']))
$query['category'] = absint($filter['category']);

在调用wp_get_recent_posts{$query);方法之前

成功了!似乎 Wordpress 从其文档中遗漏了一些过滤器参数。

您还可以通过传递“s”作为过滤器来发送搜索过滤器

$query['s'] = $filter['s'];

关于WordPress API 按类别获取帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22968236/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com