Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 仅在wordpress中搜索帖子标题以获取标题和ID_Php_Android_Wordpress - Fatal编程技术网

Php 仅在wordpress中搜索帖子标题以获取标题和ID

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

我是一名android开发者。我在我的主机上创建了一个php文件,其中包括
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

我已经在你的旧帖子里给了你答案,看,我已经在你的旧帖子里给了你答案,看