最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Types plugin custom post add_action hooks

programmeradmin2浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

Try 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
}
发布评论

评论列表(0)

  1. 暂无评论