Skip to content

Instantly share code, notes, and snippets.

@jmarreros
Last active February 27, 2017 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmarreros/27904a44ce3cce806cb385b9d65a2c5d to your computer and use it in GitHub Desktop.
Save jmarreros/27904a44ce3cce806cb385b9d65a2c5d to your computer and use it in GitHub Desktop.
Lista Subcategorías WordPress
<?php
// $list_subcat = get_terms( ['taxonomy' => 'category', 'hide_empty' => false, 'parent' => $cat] );
// $list_subcat = get_categories( ['hide_empty' => false, 'parent' => $cat] );
$list_subcat = array();
if ( !empty($cat) ) $list_subcat = get_categories( ['hide_empty' => false, 'parent' => $cat] );
if ( count($list_subcat)):
echo "<div class='subcat'>";
foreach ($list_subcat as $item_subcat) {
$category_link = get_category_link( $item_subcat->term_id );
echo '<div>';
echo '<h3><a href="'.$category_link.'">'.$item_subcat->name.'</a></h3>';
echo '<div><a href="'.$category_link.'">'.$item_subcat->description.'</a></div>';
echo '</div>';
}
echo "</div>";
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment