• Resolved russnem

    (@russnem)


    Greetings,

    I’m trying to use the REST API to pull the JSON for courses by a specific instructor in a category. I’ve got the categories sorted but can’t seem to discover the way to limit by instructors. These do not work (they ignore the instructor ID):

    /wp-json/wp/v2/courses?course-category=509&course-instructor=4
    /wp-json/wp/v2/courses?course-category=509&course-instructors=4
    /wp-json/wp/v2/courses?course-category=509&instructors=4

    Thanks,
    Russ

Viewing 1 replies (of 1 total)
  • Plugin Contributor Alex Sanford

    (@alexsanford1)

    Currently, the REST API endpoint for courses does not support filtering by teacher. However, you should be able to add it using the following code snippet (but make sure to test and be sure there aren’t unintended consequences!)

    add_action( 'rest_api_init', function() {
    	add_post_type_support( 'course', 'author' );
    } );

    After adding, you should be able to filter using the author URL parameter.

Viewing 1 replies (of 1 total)

The topic ‘REST API: Courses by Instructor(s)’ is closed to new replies.