Skip to content

Custom post type push/pull #1349

@homeclothesfree-CFL

Description

@homeclothesfree-CFL

Describe your question

I read the documentation about custom post type needing to be registered with rest API and I am trying to get several CPTs set for distributor. I found this code on the WP and added to my theme functions file but no change.

add_filter(` 'register_post_type_args', 'my_post_type_args', 10, 2 );

function my_post_type_args( $args, $post_type ) {

    if ( 'book' === $post_type ) {
        $args['show_in_rest'] = true;

        // Optionally customize the rest_base or rest_controller_class
        $args['rest_base']             = 'books';
        $args['rest_controller_class'] = 'WP_REST_Posts_Controller';
    }
    return $args; } 

Is there something I am missing?

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:questionFurther information is requested.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions