It might help, little format,and use variable to return entire html if needed to make it function,
<?php
function formatOutput()
{
$term_slug = get_query_var( 'term' );
$taxonomyName = get_query_var( 'taxonomy' );
$current_term = get_term_by( 'slug', $term_slug, $taxonomyName );
$args = array( 'child_of' => $current_term->term_id, 'hide_empty'=>false);
$terms = get_terms( 'tagportifolio', $args);
$assoc = taxonomy_image_plugin_get_associations();
$output="";
if (!empty($terms))
{
foreach($terms as $child )
{
if(array_key_exists( $child->term_taxonomy_id, $assoc ))
{
$output .= wp_get_attachment_image( $assoc[$child->term_taxonomy_id], array(), false, 'thumbnail');
}
$output .= "<a href=get_term_link( $child->name, $taxonomyName ) >$child->name;</a >";
}
}
else
{
/* else code : might be empty output*/
$output .= '';
}
return $output;
}
?>
4
solved How to wrap php code inside a function? [closed]