'wpcf7_contact_form', 'post_status' => 'publish', ]); // If we already made the same form, return the ID. foreach ($query->posts as $post) { $postMeta = get_post_meta($post->ID, 'extendify_form_type', true); if ($postMeta === $template) { return $post->ID; } } $form = \wpcf7_save_contact_form(['title' => $title]); if (!$form) { return false; } add_post_meta($form->id(), 'extendify_form_type', $template); return $form->id(); } }