Php 仅在wordpress中搜索帖子标题以获取标题和ID
我是一名android开发者。我在我的主机上创建了一个php文件,其中包括Php 仅在wordpress中搜索帖子标题以获取标题和ID,php,android,wordpress,Php,Android,Wordpress,我是一名android开发者。我在我的主机上创建了一个php文件,其中包括wp blog header.php。我在我的应用程序中将此文件用作web服务 在我的应用程序中,有一个搜索部分,我将term作为字符串和category作为用户id,并将它们发送到我的php文件中 现在,我想搜索帖子标题,并返回用户想要的标题和ID function customSearch($term,$category){ . . //To search by title and limit by category
wp blog header.php
。我在我的应用程序中将此文件用作web服务
在我的应用程序中,有一个搜索部分,我将term
作为字符串和category
作为用户id,并将它们发送到我的php文件中
现在,我想搜索帖子标题,并返回用户想要的标题和ID
function customSearch($term,$category){
.
. //To search by title and limit by category
.
}
我使用了prepare函数来获取文章,比如下面的函数,但是我找不到任何只在文章标题中搜索的函数
function getLastItems()
{
$args = array(
'numberposts' => 5,
'offset' => 0,
'category' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish',
'suppress_filters' => true );
$recent_posts = wp_get_recent_posts( $args, ARRAY_A );
$mjson = array();
foreach( $recent_posts as $recent ){
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($recent['ID']), array(400,300) );
$url_img = $thumb['0'];
$marr = array(
'id'=>$recent["ID"],
'title'=>$recent["post_title"],
'img'=>$url_img
);
array_push($mjson,$marr);
}
return $mjson ;
}//end get last items
我已经在你的旧帖子里给了你答案,看,我已经在你的旧帖子里给了你答案,看