Web Hosting
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Call WordPress rest api using links/url

Discussion in 'Misc WordPress Requests' started by tejasbramhecha, Oct 10, 2017.

  1. tejasbramhecha

    Guest

    Reply To: Call WordPress rest api using links/url, by tejasbramhecha

    Hi @jakept,

    I’m now able to access portfolio data using wp rest api but the json that I’m getting is not having any category id/tag mentioned in it. Will you please let me know what can be done to make sure that I get category id/tag?

    I have written code as following:


    /**
    * Add REST API support to an already registered post type.
    */
    add_action( 'init', 'my_custom_post_type_rest_support', 25 );
    function my_custom_post_type_rest_support() {
    global $wp_post_types;

    //be sure to set this to the name of your post type!
    $post_type_name = 'startapp_portfolio';
    if( isset( $wp_post_types[ $post_type_name ] ) ) {
    $wp_post_types[$post_type_name]->show_in_rest = true;
    $wp_post_types[$post_type_name]->rest_base = $post_type_name;
    $wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller';

    }
    }


    Thanks,

    Reply To: Call WordPress rest api using links/url
     
    #1

Share This Page

Web Hosting