Tagged: ,

Viewing 2 reply threads
  • Author
    • #7825

      Hi, using your examples, I set up a CPT that is using the post content field in the posts table, but displayed using piklist among my other meta fields. The problem with this (I just discovered) is that unless I put it into the “support” array in the register post type command, it will NOT show in the REST response. Any idea how to include it in the REST response without displaying it (now a second time and out of order) in my CPT admin edit screen?

    • #7826

      Well, I found a workaround for this:

      add_action( 'init', 'my_custom_rest_support', 25 );
        function my_custom_rest_support() {
      register_rest_field( 'my-cpt','long_description',
                  'get_callback'    => 'get_long_desc',
                  'update_callback' => '',
                  'schema' => post
      function get_long_desc( $post_id ) {
      global $post;
      $post_content = get_post(get_the_ID());
      $content = $post_content->post_content;
          return $content;

      So even though this is not showing twice in the admin, I can nevertheless add the field to the json REST response. Hope this helps someone else out…

    • #7841

      Thanks for the tip!

Viewing 2 reply threads
  • The topic ‘REST API problem with post_content field’ is closed to new replies.