Modifying Footnote Plugin for Descriptive Title Attributes

I’ve been struggling for a couple hours now to get this working… Hopefully someone here can help me.

I just started using the wp-footnotes plugin, and I’m trying to set the title attribute on backlinks to “Return to footnote # in the text.” where # = the footnote number.

Read More

Below is what I tried, putting the $id_num variable in the title attribute, but it ends up just displaying as the number of footnotes that exist. You can see this at my development site on the first post.

Thank you so much in advance for any help.

It’s quite a bit, so I’ll paste the code in at the end:

    // Display identifiers      
    foreach ($identifiers as $key => $value) {
        $id_id = "identifier_".$key."_".$post->ID;
        $id_num = ($style == 'decimal') ? $value['use_footnote']+$start_number : $this->convert_num($value['use_footnote']+$start_number, $style, count($footnotes));

        $id_replace = $this->current_options['pre_identifier'].'<a href="'.$id_href.'" id="'.$id_id.'" title="'.$id_title.'">'.$id_num.'</a>'.$this->current_options['post_identifier'];
        if ($this->current_options['superscript']) $id_replace = '<sup>'.$id_replace.'</sup>';
    }

    // Display footnotes
    if ($display) {
        $start = ($start_number != 1) ? 'start="'.$start_number.'" ' : '';

            if ($style == 'symbol') {
                $data = $data . '<span class="symbol">' . $this->convert_num($key+$start_number, $style, count($footnotes)) . '</span> ';
            }
            $data = $data.$value['text'];
            if (!is_feed()){
                foreach($value['identifiers'] as $identifier){
                    $data = $data.$this->current_options['pre_backlink'].'
<a href="'.( ($use_full_link) ? get_permalink($post->ID) : '' ).'#identifier_'.$identifier.'_'.$post->ID.'" class="backlink"
title="Return to footnote '.$id_num.' in the text.">↩</a>'
.$this->current_options['post_backlink'];
                }

    return $data;
}

Related posts

Leave a Reply

1 comment

  1. I think you just need to replace this:

    "Return to footnote '.$id_num.' in the text."
    

    with this:

    "Return to footnote '.$identifier.' in the text."
    

    The $id_num is used in the “Display identifiers” loop, but what you want to edit is the “Display footnotes” loop.