Created
June 7, 2016 01:13
-
-
Save alandbh/f812812247ea5dd32d1ad8d8d9b2db11 to your computer and use it in GitHub Desktop.
Inserção de post (ou custom post) via frontend
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if ( isset( $_POST['submitted'] ) && isset( $_POST['post_nonce_field'] ) && wp_verify_nonce( $_POST['post_nonce_field'], 'post_nonce' ) ) { | |
| $postTitleError = ''; | |
| if ( isset( $_POST['submitted'] ) ) { | |
| if ( trim( $_POST['postTitle'] ) === '' ) { | |
| $postTitleError = 'Please enter a title.'; | |
| $hasError = true; | |
| } | |
| } | |
| global $wpdb; | |
| $user_id = get_current_user_id(); | |
| $areas = $_POST['area']; | |
| $post_information = array( | |
| 'post_title' => wp_strip_all_tags( $_POST['postTitle'] ), | |
| 'post_content' => $_POST['postContent'], | |
| 'post_type' => 'projetos', | |
| 'post_status' => 'publish' | |
| ); | |
| //wp_insert_post( $post_information ); | |
| $post_id = wp_insert_post($post_information); | |
| $descricao_do_problema = $_POST['descricao_do_problema']; | |
| add_post_meta($post_id, 'descricao_do_problema', $descricao_do_problema, true); | |
| $bool_formacao_especifica = $_POST['formacao_especifica']; | |
| add_post_meta($post_id, 'formacao_especifica', $bool_formacao_especifica, true); | |
| $qual_formacao = $_POST['qual_formacao']; | |
| add_post_meta($post_id, 'qual_formacao', $qual_formacao, true); | |
| $outra_formacao = $_POST['outra_formacao']; | |
| add_post_meta($post_id, 'outra_formacao', $outra_formacao, true); | |
| wp_set_object_terms( $post_id, $areas, 'area' ); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment