我正在尝试使用创建Windows应用商店应用IdeaPress, 这取决于JSON API Plugin. 不幸的是,请求最近发布的文章只会返回
<!--more-->
标记。不过,我想展示整个帖子。有什么办法吗?This 是我的json代码。
我正在尝试使用创建Windows应用商店应用IdeaPress, 这取决于JSON API Plugin. 不幸的是,请求最近发布的文章只会返回
<!--more-->
标记。不过,我想展示整个帖子。有什么办法吗?This 是我的json代码。
您可以尝试仅在JSON API中显示完整的帖子内容:
function remove_more_wpse_96740($content) {
if(get_query_var(\'json\')){
global $post;
$content = preg_replace(\'/<!--more(.*?)?-->/\',\'\',$post->post_content);
}
return $content;
}
add_filter(\'the_content\', \'remove_more_wpse_96740\',1);
通过针对json
查询变量并删除<!--more-->
部分职位。如果您有自定义字符串,如<!--more But wait, there\'s more! -->
, 它也将被删除。
插件的这一部分/json-api/models/post.php
:
function set_content_value() {
global $json_api;
if ($json_api->include_value(\'content\')) {
$content = get_the_content($json_api->query->read_more);
$content = apply_filters(\'the_content\', $content);
$content = str_replace(\']]>\', \']]>\', $content);
$this->content = $content;
} else {
unset($this->content);
}
}
正在获取内容并检查<!--more(.*?)?-->
中的内容在WordPress函数中发生get_the_content()
.PS: 使用上述方法将禁用<!--noteaser-->
在JSON API中,但这应该没问题,因为您需要完整的post内容。
我编写了一个脚本,以XML格式显示按类别组织的所有WordPress帖子。代码为// get all the categories from the database $cats = get_categories(); header(\'Content-type: text/xml\'); echo \'<categories>\'; // loop through the categries foreach ($cats as $cat) {