2016-08-17 10:05
浏览 79


I am now creating an android app which planned to connect to a plugin(WP Job Manager) in my WordPress side. I installed REST-API plugin and successfully getting posts by:

However, results do not include custom posts which created by the plugin. I am new in rest-api and I am not sure what I should do.


图片转代码服务由CSDN问答提供 功能建议

我现在正在创建一个Android应用程序,计划连接到我的WordPress端的插件(WP作业管理器)。 我安装了REST-API插件并成功获取帖子:
   \  n 

但是,结果不包括插件创建的自定义帖子。 我是rest-api的新手,我不知道该怎么做。

谢谢你 !

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dtio35880438 2016-08-17 17:36

    There are solutions, but the basic idea is that the custom post type must be registered with WP REST API.

    You can refer to this link:

    It should be something like this (put it in your functions.php, "cpt" = Custom Post Type, an arbitrary name):

    function wpsd_add_cpt_args() {
        global $wp_post_types;
        $wp_post_types['cpt']->show_in_rest = true;
        $wp_post_types['cpt']->rest_base = 'cpt';
        $wp_post_types['cpt']->rest_controller_class = 'WP_REST_Posts_Controller';
    add_action( 'init', 'wpsd_add_cpt_args', 30 );
    点赞 评论

相关推荐 更多相似问题