For example, if I’m building a list in a plugin that loops over an array to produce a list ul or ol. I typically see code as follows.

foreach($list as $item) {
  $output .= '<li>' . $item['value'] . '</li>';
}

I guess I’m looking to see if there is a comparable to such functions in the Drupal world such as theme_list() (reference). I’m looking to give my list of items to a function and have it write the HTML block in a standardized way.

2 Answers
2

There are specific functions like wp_list_categories() and wp_list_pages() along with some others which will do this for you but for arbitrary arrays, WordPress doesn’t have a function to neatly print it out into HTML for you. You could simply write your own functions for this purpose if you really need to I guess.

Leave a Reply

Your email address will not be published. Required fields are marked *