Title: Insert via php
Last modified: August 21, 2017

---

# Insert via php

 *  Resolved [sergiosala](https://wordpress.org/support/users/sergiosala/)
 * (@sergiosala)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/insert-via-php/)
 * Can I insert via php or shortcode especifically to a blog post? Which code should
   I use?
    -  This topic was modified 8 years, 9 months ago by [sergiosala](https://wordpress.org/support/users/sergiosala/).

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

 *  [Steven](https://wordpress.org/support/users/shazahm1hotmailcom/)
 * (@shazahm1hotmailcom)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/insert-via-php/#post-9431284)
 * [@sergiosala](https://wordpress.org/support/users/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.
 *  Thread Starter [sergiosala](https://wordpress.org/support/users/sergiosala/)
 * (@sergiosala)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/insert-via-php/#post-9431339)
 * 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?
 *  [Steven](https://wordpress.org/support/users/shazahm1hotmailcom/)
 * (@shazahm1hotmailcom)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/insert-via-php/#post-9431496)
 * [@sergiosala](https://wordpress.org/support/users/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!

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

The topic ‘Insert via php’ is closed to new replies.

 * ![](https://ps.w.org/easy-table-of-contents/assets/icon-256x256.png?rev=3045459)
 * [Easy Table of Contents](https://wordpress.org/plugins/easy-table-of-contents/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/easy-table-of-contents/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/easy-table-of-contents/)
 * [Active Topics](https://wordpress.org/support/plugin/easy-table-of-contents/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/easy-table-of-contents/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/easy-table-of-contents/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Steven](https://wordpress.org/support/users/shazahm1hotmailcom/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/insert-via-php/#post-9431496)
 * Status: resolved