WordPress“ REST API”-呈现VisualComposer内容不起作用

时间:2018-09-18 04:47:31

标签: wordpress wordpress-rest-api visual-composer

我已经使用了以下代码,但无法正常工作,自定义标题和单个图片简短代码显示在应用程序中。谁能帮我解决问题。谢谢。

add_action( 'rest_api_init', function ()
{
   register_rest_field(
          // if you need it to work with other (even custom post) types,
          // then you have to use an array:
          // array( 'page', 'post', 'custom_post_type', 'etc' )
          // this example only does the trick for 'page'
          // look at the link in the first EDIT section of this answer
          'page',
          'content',
          array(
                 'get_callback'    => 'compasshb_do_shortcodes',
                 'update_callback' => null,
                 'schema'          => null,
          )
       );
});

function compasshb_do_shortcodes( $object, $field_name, $request )
{
   WPBMap::addAllMappedShortcodes(); // This does all the work

   global $post;
   $post = get_post ($object['id']);
   $output['rendered'] = apply_filters( 'the_content', $post->post_content );

   return $output;
}

0 个答案:

没有答案