From the look of your code, all you are doing is creating a nested list. If so, the easiest thing would be wp_list_pages
.
$args = array(
'post_type' => 'cliente',
'post_status' => 'publish',
'author' => $idutente, // must be comma separated list of IDs
);
wp_list_pages($args);
wp_list_pages
only seems to work with 'hierarchical' => true,
, but you have registered your CPT with that argument.
You should be able to style it with CSS however you want.
If you need something more complicated, you may need a custom Walker, something like this:
class My_Page_Walker extends Walker_Page {
function end_el( &$output, $page, $depth = 0, $args = array() ) {
$link = get_edit_post_link($page->ID);
$link = '<a class="post-edit-link" href="' . $link . '">Edit</a>';
$output .= ' ('.$link.') </li>';
}
}
$args = array(
'post_type'=>'cliente',
'post_status'=> 'publish',
'walker' => new My_Page_Walker
);
wp_list_pages( $args );