Skip to content
Public Ticket #26595

Post template

Conversation thread

PenciDesign Supporter replied

Staff Reply

Hi,

For this specific situation, please send me your WordPress admin account details through a PRIVATE message. I will then log in and make an effort to assist you in diagnosing and resolving this issue.

Regards,
PenciDesign.


PenciDesign Supporter replied

Staff Reply

Hi,

You should insert this code either into the functions.php file of the child theme or by using the CodeSnippet plugin available here: https://wordpress.org/plugins/code-snippets/

add_filter( 'register_post_type_args', 'soledad_template_post_type_args', 10, 2 );
function soledad_template_post_type_args( $args, $post_type ) {
    if ( 'custom-post-template' === $post_type ) {
        $args['show_in_rest'] = true;         // Optionally customize the rest_base or rest_controller_class
        $args['rest_base']             = 'custom-post-template';
        $args['rest_controller_class'] = 'WP_REST_Posts_Controller';
    }     return $args;
}

Now you can get the post template data via this URL: https://yoursite.com/wp-json/wp/v2/custom-post-template/

Regards,
PenciDesign.



Want to join this conversation or access attachments? Sign in first.