Title: executing php code in custom post type
Last modified: March 26, 2022

---

# executing php code in custom post type

 *  [miko1997](https://wordpress.org/support/users/miko1997/)
 * (@miko1997)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/executing-php-code-in-custom-post-type/)
 * hello, i wanted to execute a php code when a new custom post type is created…
   so when a customer creates a wordpress post from frontend the php code will be
   executed can you help me

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

 *  [Sruthy@xyzscripts](https://wordpress.org/support/users/sruthy123/)
 * (@sruthy123)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/executing-php-code-in-custom-post-type/#post-15501324)
 * If you want to execute php code only on custom post type,you can use
    is_singular(
   $post_types ) function.For example if you want to display something only on custom
   post type book, then you can use like following if(is_singular( ‘book’ )) { echo“
   Hii”; }
    -  This reply was modified 4 years, 2 months ago by [Sruthy@xyzscripts](https://wordpress.org/support/users/sruthy123/).
 *  Thread Starter [miko1997](https://wordpress.org/support/users/miko1997/)
 * (@miko1997)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/executing-php-code-in-custom-post-type/#post-15506265)
 * thank you that worked fine

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

The topic ‘executing php code in custom post type’ is closed to new replies.

 * ![](https://ps.w.org/insert-php-code-snippet/assets/icon-128x128.png?rev=1800967)
 * [Insert PHP Code Snippet](https://wordpress.org/plugins/insert-php-code-snippet/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php-code-snippet/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php-code-snippet/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php-code-snippet/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php-code-snippet/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php-code-snippet/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [miko1997](https://wordpress.org/support/users/miko1997/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/executing-php-code-in-custom-post-type/#post-15506265)
 * Status: not resolved