1. Home
  2. Knowledge Base
  3. API
  4. Function Reference
  5. Function Reference: wlmapi_the_level_posts

Function Reference: wlmapi_the_level_posts

Retrieves all posts of the specified level passed through the filter: wlmapi_the_level_posts. If no filter is applied, this function will return the unfiltered array, i.e. the same output as wlmapi_get_level_posts.

Parameters

  • level_id (int) – The ID of the level to retrieve posts from

Return

Returns a string containing the filtered list.

Example Code

<?php
     //On the page displaying the list
     $posts = wlmapi_the_level_posts(1340726008);
     print_r($posts);

     //Inside the theme functions file or a plugin
     function filter_posts($posts) {
          //Navigate down to the posts array
          $posts_array = $posts['posts']['post'];

          //Loop through posts array
          foreach ( $posts_array as $post ) {
               $output .= '<ul>';
               $output .= '<li>' . $post['ID'] . '</li>';
               $output .= '<li>' . $post['name'] . '</li>';
               $output .= '</ul>';
          }

          return $output;
     }

     add_filter('wlmapi_the_level_posts', 'filter_posts');
?>

Example Output

  • 1
  • Hello world!
  • 96
  • Auto Reg

Notes

This functions returns WLMAPIMethods::the_level_posts() in core/api-helper/class-api-methods.php

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support