I am using this shortcode to produce a list of child pages of a specified parent. I would like to replace the list items default discs with a font awesome icon. According to the font awesome documentation it is done like this:
<ul class="fa-ul">
<li><span class="fa-li"><i class="fas fa-spinner fa-pulse"></i></span>replace bullets</li>
</ul>
And this is the code I am using to to generate my list of items:
function childpages_shortcode_callback( $atts ) {
$atts = shortcode_atts( array(
'parent' => false,
), $atts, 'childpages' );
$parent_id = false;
if ( $atts['parent'] ) {
$parent = get_page_by_path( $atts['parent'] );
if ( $parent ) {
$parent_id = $parent->ID;
}
} else { // if no parent passed, then show children of current page
$parent_id = get_the_ID();
}
$result = '';
if ( ! $parent_id ) { // don't waste time getting pages, if we couldn't get parent page
return $result;
}
$childpages = wp_list_pages( array(
'sort_column' => 'menu_order',
'title_li' => '',
'child_of' => $parent_id,
'echo' => 0
) );
if ( $childpages ) {
$result =
'<h2>' . get_the_title( $parent_id ) . '</h2>' .
'<ul class="fa-ul">' . $childpages . '</ul>';
}
return $result;
}
add_shortcode( 'childpages', 'childpages_shortcode_callback' );
As you can see I have managed to add the "fa-ul" class to the resulting unordered list, but I cannot work out how to add the span and i elements between the li tags.
Normally I would just prepend these with jQuery and call it a day, but I would like to know if there is a wordpress approach?
Thankyou