joli_toc_headings

Filters the headings array before output.

$headings has the following offsets:

  • id
  • title
  • depth
add_filter('joli_toc_headings', 'filter_headings', 10, 2);

// Example how to capitalize all the headings
function filter_headings( $headings ){ 
    $headings = array_map(function($heading){
        //for H2 only
        if ($heading['depth'] == 2){
            //Capitalizes the first word only
            $heading['title'] = ucfirst(strtolower($heading['title']));
        }
        return $heading;
    }, $headings);

    return $headings;
}
Was this page helpful?