Function Reference: wlmapi_get_level_post_type

Retrieves all posts of the specified post type associated with the specified level.

Parameters

  • level_id (int) – The ID of the level to retrieve posts from
  • post_type (string) – The slug of the post type to retrieve posts for

Return

Returns a multi-dimensional array containing data for each post.

Example Code

<?php
     $posts = wlmapi_get_level_post_type(1340726008, 'lesson');
     print_r($posts);
?>

Example Output

Array
(
    [success] => 1
    [posts] => Array
        (
            [post] => Array
                (
                    [0] => Array
                        (
                            [ID] => 1
                            [name] => Hello world!
                            [_more_] => /levels/1340726008/posts/1
                        )

                    [1] => Array
                        (
                            [ID] => 96
                            [name] => Auto Reg
                            [_more_] => /levels/1340726008/posts/96
                        )

                )

        )

    [supported_verbs] => Array
        (
            [0] => GET
            [1] => POST
        )

)

Notes

This functions returns WLMAPIMethods::get_level_post_type($level_id, $post_type) in core/api-helper/class-api-methods.php