@sergiosala
You can already do this… Disable the “Auto Insert” for the desired post types on the Settings : Table of Contents admin page.
When adding a new page or post enable the “Insert table of contents.” option on that page/post.
Hope that helps, let me know.
Ok, but what I want is to add the Table of content in the sidebar automatically, every time a user choose a template. In this template I want to add the TOC via php. How can I do it?
@sergiosala
I see…
Probably the easiest solution is to hook into the save_post_{$type} filter check for the chosen template and set the post meta _ez-toc-insert key to true. There is no function available in PHP where you can just add to a template file to output the TOC because that occurs within coree WP filters based on the post meta and/plugin setting values.
Hope this helps!