<div class="choose-template"> <span>Templates</span> </div> <ul> <?php foreach (get_templates_list() as $key => $value) { ?> <li><a href="<?php echo site_url($value['link']); ?> "><?php echo $value['title']; ?> </a></li> <?php } ?> </ul>
/** * The function returns array with all avialable templates * * @param mixed $types Type name of list of types as array * @return array $template_array List of template with type and subtype as keys and name as values */ function get_templates_array($types) { $template_array = array(); // If templates not found, return empty array $template_list = get_templates_list($types); // Get templates file list foreach ($template_list as $type => $list) { foreach ($list as $filename) { $basename = basename($filename); $basename = preg_replace('/\\.(tpl|xml)$/', '', $basename); list($subtype, $name) = explode('_', $basename, 2); $template_array[$type][$subtype] = strtolower($name); } } return $template_array; }
<div class="choose-template"> <span>Other Templates</span> </div> <ul> <?php $templates = get_templates_list(); ?> <?php unset($templates[$current]); ?> <?php foreach ($templates as $key => $value) { ?> <li><a href="<?php echo site_url($value['link']); ?> "><?php echo $value['title']; ?> </a></li> <?php } ?> </ul>