I'm using the wp-types plugin to create a custom post type. I'm developing my own plugin which I need to fire whenever a post of my custom post type is updated.
Right now add_action( 'save_post', 'myFunc');
will fire if a regular post is updated, however not if one of of the custom posts is updated.
Does anyone know why this might be? Thanks!
I'm using the wp-types plugin to create a custom post type. I'm developing my own plugin which I need to fire whenever a post of my custom post type is updated.
Right now add_action( 'save_post', 'myFunc');
will fire if a regular post is updated, however not if one of of the custom posts is updated.
Does anyone know why this might be? Thanks!
Share Improve this question asked May 11, 2015 at 18:51 James MyersJames Myers 155 bronze badges1 Answer
Reset to default 1Try this way:
add_action( 'save_post', 'myFunc');
function myFunc(){
if ($post->post_type == 'cpt' ) {
// do action here
}
OR
add_action( 'save_post', 'myFunc');
function myFunc(){
if ( 'cpt' == get_post_type() ) {
// do action here
}