0

I've been searching in the codex from wordpress and search through google but didn't find any function or any code that can help me.

I want to build a conditional that when there is a new custom post type should do something automatically(in one case specific create a marker in a map).

Any suggestion?

Thanks

  • When a Custom Post of a Post Type is created? The save_post hook is well enough for that, checking against the $post->post_type. – Howdy_McGee Nov 22 '17 at 17:18
0

You can do something on a post creation with the action save_post_...

$customPostType = "custom";


add_action("save_post_" . $customPostType, function ($post_ID, \WP_Post $post, $update) {

    if (!$update) {
        // creation of the custom post
        // ...

        return;
    }


    // updating of the custom post
    // ...



}, 10, 3);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.