• Resolved Cristescu Bogdan

    (@cbogdan)


    Hi there,

    Great plugin and thank you all for this! I integrate it with success but I am stuck in this situation. I have the ToC list at the beginning of the posts and I create a “back to ToC” link that follow user on the scroll. Every thing it is ok, except that not all my posts have headings! Can this plugin send me a response trough a function so I can condition the appearing of my back to ToC link?

    It will be also a great feature for this module, to have this arrow link back to ToC at every heading, like an option with toggle on/off!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Steven

    (@shazahm1hotmailcom)

    Are you using the auto insert? If you are you can hook into the ez_toc_maybe_apply_the_content_filter filter. It has one parameter which returned a bool (true|false).

    I hope this helps!

    Thread Starter Cristescu Bogdan

    (@cbogdan)

    Thank you Steven for your suggestion but I think it is just one step to solve my issue. I use this code, and I succed to have a positive effect:

    <?php 
    $toctoc = apply_filters( 'ez_toc_maybe_apply_the_content_filter', 'true' );
    if($toctoc==true ) { ?>
    <a class="to-the-top" href="#ez-toc-container" title="Back to Contents">
    <span class="to-the-top-long"><?php printf( __( 'Contents %s', 'twentytwenty' ), '<span class="arrow" aria-hidden="true">&uarr;</span>' ); ?></span></a>
    <?php } else { ?>
    <a class="to-the-top" href="#wrapper" title="Go Up">
    <span class="to-the-top-long"><?php printf( __( 'Up %s', 'twentytwenty' ), '<span class="arrow" aria-hidden="true">&uarr;</span>' ); ?></span></a>
    <?php } ?>

    Now I can have the “Up to top” on home page, categories and all other pages like before to start to change the scope of this link. But on single post it does not work. The filter return true even if there are no headings, witch for ToC module this does not mean that he can not output the table. I need something similar but to return false if the ToC module can not filter the content to output the ToC list inside. I read the code of your plugin and in the philosophy of your script this check has no place. But, maybe you can help me to use the same checking to find out if a post content has or not headings, because your module only the should do something, so there I can hook in also!

    Steven

    (@shazahm1hotmailcom)

    Sorry, but unless I do not understand… the code you share is wrong. You do not use the apply_filters() function, you use the add_filter() to hook into the ez_toc_maybe_apply_the_content_filter

    The code you show will at all times be true because you are not actually hooking into the filter.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘ToC conditional tags: if has headings or not’ is closed to new replies.