• Hi,

    I was just wondering if you could consider giving us the option to choose what headers to display in the TOC on a per post basis? My header structure does vary a bit from one post to the other and sometimes I only want to show h2 an d h3, and sometimes both h2,h3, and h4 in the TOC. So being able to override the defaults for specific posts would be great.

    Perhaps this could be in the Pro version?

    If not, then I was considering if it would be possible to build that functionality myself using the header filter and AFC for options. Do you think that would be possible?

    Thanks

    -Espen

Viewing 1 replies (of 1 total)
  • Plugin Author WPJoli

    (@wpjoli)

    Hi,

    This is a good suggestion indeed and right now all you can do is using custom code.

    You can use this example to use in your functions.php to achieve what you want:

    
    //$headings is the array of headings passed on to the view. You can the filter out some elements here
    function filter_headings( $headings ){ 
        //Replace with your actual post id
        if ($post->ID == 100){
            $headings = array_filter($headings, function($heading){
                //heading['depth'] corresponds to the Heading depth. 2 = H2, 3 = H3 etc..
                return $heading['depth'] <= 2;
            });
        }
        return $headings;
    }
    
    add_filter('joli_toc_headings', 'filter_headings', 10, 2);
    

    Does this help ?

Viewing 1 replies (of 1 total)
  • The topic ‘Ability to customise headers per post?’ is closed to new replies.