Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.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
Android Wordpress自定义文章到标准RESTAPI文章_Android_Json_Wordpress_Rest - Fatal编程技术网

Android Wordpress自定义文章到标准RESTAPI文章

Android Wordpress自定义文章到标准RESTAPI文章,android,json,wordpress,rest,Android,Json,Wordpress,Rest,RESTAPI在这种组合中对我有用-domain.com/wp json/wp/v2/custom post,但我的应用程序只读标准wp/v2/posts 如何将自定义帖子添加到标准Wordpress类别和RESTAPI 我将自定义帖子添加到普通类别,但在RESTAPI帖子中仍然看不到自定义帖子 add_action( 'init', 'myfuncxx'); function myfuncxx() { register_taxonomy_for_object_type( 'catego

RESTAPI在这种组合中对我有用-domain.com/wp json/wp/v2/custom post,但我的应用程序只读标准wp/v2/posts

如何将自定义帖子添加到标准Wordpress类别和RESTAPI

我将自定义帖子添加到普通类别,但在RESTAPI帖子中仍然看不到自定义帖子

add_action( 'init', 'myfuncxx'); function myfuncxx() {
    register_taxonomy_for_object_type( 'category', 'review' );
}

add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
  if( is_category() ) {
    $post_type = get_query_var('review');
    if($post_type)
        $post_type = $post_type;
    else
        $post_type = array('nav_menu_item', 'post', 'review'); // don't forget nav_menu_item to allow menus to work!
    $query->set('post_type',$post_type);
    return $query;
    }
}

add_action( 'init', 'add_myCustomPostType_endpoint');
function add_myCustomPostType_endpoint(){

    global $wp_post_types;
    $wp_post_types['review']->show_in_rest = true;
    $wp_post_types['review']->rest_base = 'posts';
    $wp_post_types['review']->rest_controller_class = 'WP_REST_Posts_Controller';
}

您可以在注册帖子类型时添加
show_in_rest
…我有这个
$wp_post_types['review']->show_in_rest=true$wp_post_类型['review']->rest_base='posts'$wp_post_type['review']->rest_controller_class='wp_rest_Posts_controller'我在REST API中看到了自定义帖子(wp json/wp/v2/review)-但我想将此帖子添加到标准API链接(帖子,无评论)您可以在注册帖子类型时添加
show_in_REST
…我有这个
$wp_post_types['review']->show_in_REST=true$wp_post_类型['review']->rest_base='posts'$wp_post_type['review']->rest_controller_class='wp_rest_Posts_controller'我在RESTAPI中看到了自定义帖子(wp-json/wp/v2/review)-但我想将此帖子添加到标准API链接(帖子,无评论)