• Hi there,

    Can you please guide me how to use this plugin with custom fields? Because there is no option and I wish to continue using your plugin and not change it, so let me know if it is possible with some fix.

    I am using ACF.

    _Mairaj

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor pewgeuges

    (@pewgeuges)

    Hi @muhammadmairaj,

    Thank you for your valuable feature request, that raised already much concern with this and at least one other plugin (EFN) alike.

    Much like when footnotes are in the text of a widget or in the content of a popup, processing footnotes in the content of a custom field requires that when the custom field is displayed, certain filters be applied. Footnotes adds filters to the following hooks, per current version; to see them in the code:

    https://plugins.trac.wordpress.org/browser/footnotes/tags/2.7.3/class/task.php#L434

    From that code, the full list of filtered hooks, beside wp_head and wp_footer filtered for output only, is:

    1. the_title
    2. the_content
    3. term_description
    4. pum_popup_content
    5. the_excerpt
    6. widget_title
    7. widget_text

    From this I conclude that it depends on how a custom field is implemented. This is the code to apply one of these filters:

    $the_custom_field_content = apply_filters( 
      'the_desired_hook_name', 
      $the_custom_field_content
    );

    Does that make sense? I hope that ACF does apply filters added to one of the cited hooks.

    Out of curiosity, may I ask your which other footnotes plugin you consider using on failure of the Footnotes plugin to process footnotes in custom fields? As far as I know, other footnotes plugins may apply filters to less than the hooks listed above. E.g. the filter for pum_popup_content was added on request.

    If we know the hook name that ACF applies the filters of, hopefully the Footnotes authors will add it likewise. Meanwhile, what I’m suggesting to do is applying the filters of one of the above hooks, conversely, when displaying the custom field. Sort of a quick fix.

    Please let us know whether that solves the issue.

    Thread Starter mmuhammadmairaj

    (@muhammadmairaj)

    Hi there,

    Thank you so much for the kind reply.

    I haven’t checked out other plugins thoroughly yet, as I was convinced this plugin would have some workaround for me.

    Anyway, I implemented the filter like you said. It’s working, but the references’ section is displaying right after the field disturbing other fields on the page and the page flow.

    Take a look here: https://superstarsbio.com/bios/ayesha-sana/

    I am using the_content hook and need to use footnotes in multiple fields like you can see on the given page. Thank you so much for prompt response. :))

    Also the_content filter trick of footnotes is not working on ACF plain text fields. :((

    Also you can go through ACF documentation to see what filters they use and alter your plugin’s coding accordingly.

    Plugin Contributor pewgeuges

    (@pewgeuges)

    @muhammadmairaj,

    No problem. Thank you for the insights. In wysiwyg fields, ACF applies the filters added to acf_the_content. Footnotes not working in plain text seems normal to me because of multiple Footnotes features requiring markup.

    The references’ section displaying right after the field is often the expected behavior as in https://wordpress.org/support/topic/enhancement-request-8/ But you rightfully require that on the website you are running, footnotes be reunited at the bottom of the page. To achieve that, these custom fields would ideally be part of the content, and footnotes would be processed all at once when filters like the one added by Footnotes are applied to the_content.

    Alternatively, custom fields might be appended to the post and add up to enhance the content if priority is higher than the one that the Footnotes filter is added with. This is controlled in the Footnotes settings under the third tab.

    After all, given the trouble you are experiencing, I wonder whether custom fields are an optimal solution. Another option would be using tables instead. An already posted example with tables, footnotes, and all footnotes together at the bottom of the entry was a page of https://wikiwiki.in, but not all pages of the website do have footnotes.

    Also you can go through ACF documentation to see what filters they use and alter your plugin’s coding accordingly.

    ACF documentation is very extensive. In the plugin’s code (free version) we see the acf_the_content in the wysiwyg field content, in this file:

    https://plugins.trac.wordpress.org/browser/advanced-custom-fields/tags/5.12/includes/fields/class-acf-field-wysiwyg.php#L43

    I’m no more in a position to alter Footnotes’ code to provide quick fixes, but as it appears, that wouldn’t even be useful since fields must not be processed individually, per your requirement.

    Please let us know if we can do anything else aiming at ACF-Footnotes-integration.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to use footnotes in custom fields’ is closed to new replies.