New Post in Post Type Customized doesn’t load scripts
-
I’m having a problem with the add post of a post type customized. I have a lot of post types customized, but the problem only happen with this one.
Well, the problem is that nothing works in the add post. The toolbar don’t load, the links doesn’t work and the browser console don’t show any load script problems.
I disabled the plugins actived, but didn’t fixed.
I accept any solution suggestions.
Tks
-
There is not enough information to support on this. Can feed us more? Website URL, how do you code?
This code creates the post type:
add_action('init', 'custom_type_noticia'); function custom_type_noticia() { $labels = array( 'name' => 'Notícias Sobre o Cancer', 'singular_name' => 'Notícia', 'add_new' => 'Adicionar Novo', 'add_new_item' => 'Nova Notícia', 'edit_item' => 'Editar Notícia', 'new_item' => 'Nova Notícia', 'view_item' => 'Ver Notícia', 'search_items' => 'Procurar Notícia', 'not_found' => 'Nenhum Notícia encontrado', 'not_found_in_trash' => 'Nenhum Notícia encontrado na lixeira', 'menu_name' => 'Notícias' ); $rewrite = array( 'slug' => 'noticias-cancer' ); $args = array( 'labels' => $labels, 'public' => true, 'public_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => $rewrite, 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'menu_icon' => 'dashicons-admin-post', 'register_meta_box_cb' => 'noticias_meta_box', 'show_in_rest' => true, 'taxonomies' => array( 'post_tag' ), 'supports' => array( 'title', 'editor', 'thumbnail', 'post-formats', 'excerpt', 'revisions', 'author' ) ); register_post_type('noticias', $args); flush_rewrite_rules(); } $rewrite = array( 'slug' => 'noticia-cancer' ); register_taxonomy( 'noticias_categoria', 'noticias', array( 'label' => 'Categorias', 'singular_label' => 'Categoria', 'menu_name' => 'Categorias', 'all_items' => 'Todas as Categorias', 'edit_item' => 'Editar Categoria', 'view_item' => 'Visualizar Categoria', 'update_item' => 'Atualizar Categoria', 'add_new_item' => 'Adicionar nova Categoria', 'new_item_name' => 'Nova Categoria', 'search_items' => 'Procurar Categorias', 'rewrite' => $rewrite, 'hierarchical' => true ) ); function tipo_noticia_taxonomy() { $labels = array( 'name' => 'Tipos de notícia', 'singular_name' => 'Tipo de notícia', 'menu_name' => 'Tipos de notícia' ); $rewrite = array( 'slug' => 'noticias-cancer' ); $args = array( 'show_ui' => true, 'labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_in_rest' => true, 'query_var' => 'tipos', 'rewrite' => $rewrite ); register_taxonomy( 'tipos', 'noticias', $args ); flush_rewrite_rules(); } add_action( 'init', 'tipo_noticia_taxonomy' ); function noticias_meta_box() { add_meta_box( 'meta_box_noticias', 'Informa??es adicionais', 'noticias_meta', 'noticias', 'normal', 'high' ); } function noticias_meta(){ global $post; $autores = get_post_meta( $post->ID, 'noticias_autores', true ); $especialidade = get_post_meta( $post->ID, 'noticias_especialidade', true ); $info = get_post_meta( $post->ID, 'noticias_info', true ); $data = get_post_meta( $post->ID, 'noticias_data', true ); $fonte = get_post_meta( $post->ID, 'noticias_fonte', true ); ?> <div class="form-field"> <div class="wp-col-12"> <label for="noticias_autores">Autores</label> </div> <div class="input-sugestoes"> <div class="wp-col-10"> <input type="text" class="valor" /> <input type="hidden" class="hidden" name="noticias_autores" id="noticias_autores" value="<?php echo $autores; ?>" /> </div> <div class="wp-col-2"> <input type="button" class="button adicionar" value="Adicionar"> </div> <div class="sugestoes"> <?php $medicos = new WP_Query( array( 'post_type' => 'time-multi', 'posts_per_page' => 10000 ) ); echo '<ul>'; foreach( $medicos -> posts as $medico ) { echo '<li data-id="' . $medico -> ID . '" data-nome="' . mb_strtolower( $medico -> post_title ) . '">' . $medico -> post_title . '</li>'; } echo '</ul>'; ?> </div> <div class="tagchecklist"></div> </div> </div> <br> <div class="form-field"> <div class="wp-col-12"> <label for="noticias_especialidade">Especialidade</label> <input type="text" name="noticias_especialidade" id="noticias_especialidade" value="<?php echo $especialidade; ?>" /> </div> </div> <br> <div class="form-field"> <div class="wp-col-12"> <label for="noticias_info">Informa??es adicionais</label> <input type="text" name="noticias_info" id="noticias_info" value="<?php echo $info; ?>" /> </div> </div> <br> <div class="form-field"> <div class="wp-col-12"> <label for="noticias_data">Data</label> <input type="text" name="noticias_data" id="noticias_data" value="<?php echo $data; ?>" placeholder="dd/mm/aaaa" /> </div> </div> <br> <div class="form-field"> <div class="wp-col-12"> <label for="noticias_fonte">Fonte</label> <input type="text" name="noticias_fonte" id="noticias_fonte" value="<?php echo $fonte; ?>" /> </div> </div> <?php } add_action( 'save_post', 'save_noticias_post' ); function save_noticias_post( $post_id ) { if ( isset( $_POST['noticias_autores'] ) ) update_post_meta( $post_id, 'noticias_autores', $_POST['noticias_autores'] ); else update_post_meta( $post_id, 'noticias_autores', null ); if ( isset( $_POST['noticias_especialidade'] ) ) update_post_meta( $post_id, 'noticias_especialidade', $_POST['noticias_especialidade'] ); else update_post_meta( $post_id, 'noticias_especialidade', null ); if ( isset( $_POST['noticias_info'] ) ) update_post_meta( $post_id, 'noticias_info', $_POST['noticias_info'] ); else update_post_meta( $post_id, 'noticias_info', null ); if ( isset( $_POST['noticias_data'] ) ) update_post_meta( $post_id, 'noticias_data', $_POST['noticias_data'] ); else update_post_meta( $post_id, 'noticias_data', null ); if ( isset( $_POST['noticias_fonte'] ) ) update_post_meta( $post_id, 'noticias_fonte', $_POST['noticias_fonte'] ); else update_post_meta( $post_id, 'noticias_fonte', null ); }
This post type works:
add_action('init', 'custom_type_depoimentos'); function custom_type_depoimentos() { // Define os textos que ser?o exibidos no admin $labels = array( 'name' => 'Depoimentos', 'singular_name' => 'Depoimento', 'add_new' => 'Adicionar Novo', 'add_new_item' => 'Novo Depoimento', 'edit_item' => 'Editar Depoimento', 'new_item' => 'Novo Depoimento', 'view_item' => 'Ver Depoimento', 'search_items' => 'Procurar Depoimento', 'not_found' => 'Nenhum Depoimento encontrado', 'not_found_in_trash' => 'Nenhum Depoimento encontrado na lixeira', 'menu_name' => 'Depoimentos' ); $args = array( 'labels' => $labels, 'public' => true, 'public_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'menu_icon' => 'dashicons-format-quote', 'register_meta_box_cb' => 'depoimentos_meta_box', 'show_in_rest' => true, 'rest_base' => 'depoimentos', 'rest_controller_class' => 'WP_REST_Posts_Controller', 'supports' => array( 'title', 'editor', 'thumbnail', 'revisions' ) ); register_post_type('depoimentos', $args); flush_rewrite_rules(); } register_taxonomy( 'depoimentos_categoria', 'depoimentos', array( 'label' => 'Categorias', 'singular_label' => 'Categoria', 'menu_name' => 'Categorias', 'all_items' => 'Todas as Categorias', 'edit_item' => 'Editar Categoria', 'view_item' => 'Visualizar Categoria', 'update_item' => 'Atualizar Categoria', 'add_new_item' => 'Adicionar nova Categoria', 'new_item_name' => 'Nova Categoria', 'search_items' => 'Procurar Categorias', 'hierarchical' => true ) ); function depoimentos_meta_box() { add_meta_box( 'meta_box_depoimentos', 'Informa??es adicionais', 'depoimentos_meta', 'depoimentos', 'normal', 'high' ); } function depoimentos_meta(){ global $post; $destaque = get_post_meta( $post->ID, 'depoimentos_destaque', true ); ?> <div class="form-field"> <input type="checkbox" name="depoimentos_destaque" id="depoimentos_destaque" value="true" <?php if ( $destaque ) echo 'checked'; ?> /> <label for="depoimentos_destaque">Exibir na página inicial</label> </div> <?php } add_action( 'save_post', 'save_depoimentos_post' ); function save_depoimentos_post( $post_id ) { if( isset( $_POST['depoimentos_destaque'] ) ) update_post_meta( $post_id, 'depoimentos_destaque', $_POST['depoimentos_destaque'] ); else update_post_meta( $post_id, 'depoimentos_destaque', null ); }
Plugins list:
Advance Custom Import and Export
Akismet Anti-Spam
Contact Form 7
Contact Form Submissions
Flamingo
Redirection
WP Cerber Security & Antispam
WP REST API
WP-Mail-SMTP
Yoast SEOMy solution was changing the server and installing WordPress again.
Then, works like a charm.
- The topic ‘New Post in Post Type Customized doesn’t load scripts’ is closed to new replies.