Site icon Hip-Hop Website Design and Development

Sending submit information over REST API, the way to parse shortcodes in post_content?

I’m utilizing the REST API to publish posts outdoors of WordPress, and have run into an issue the place not all of my shortcodes are getting processed. Particularly, most of my plugins’ shortcodes are getting processed however nothing from visible composer is getting transformed to HTML. I discover that if I var_dump my REST API’s submit information operate on the entrance finish of the WordPress web site itself (clean theme, theme is actually ‘var_dump this operate’), the shortcodes for VC do get processed.

I’m not certain what I’m doing mistaken right here, however right here is my code for the REST API return:

operate return_page_single( WP_REST_Request $request ) {
    $page_id = $request->get_param( 'web page' ); 

    $args = array( 
        'id' => $page_id,
        'post_type' => 'web page',
        'posts_per_page' => 1
    );
    $question = new WP_Query( $args );

    if ( $query->have_posts() ) {
        $web page = $query->posts;
        $page_content = $web page[0]->post_content;
        $page_content = apply_filters( 'the_content', $page_content );
        $page_content = do_shortcode( $page_content );
        $web page[0]->post_content = $page_content;
        $query_return['page'] = $web page;
        $query_return['query'] = $query->question;
    }
    wp_reset_postdata();
    return $query_return;
}

If I dump the contents of my REST API outcome, I get shortcodes for VC however every little thing else processes.

If I place the next in my theme:

var_dump( return_page_single( $request ) ); 

I get the totally processed submit content material.

I haven’t got a dwell instance as that is being developed internally but when it helps to troubleshoot I can most likely set one thing up.