admin管理员组文章数量:1316323
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
}
本文标签: Types plugin custom post addaction hooks
版权声明:本文标题:Types plugin custom post add_action hooks 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742003989a2411589.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论