Title: Custom Post Type not saving
Last modified: August 31, 2016

---

# Custom Post Type not saving

 *  Resolved [Bensji](https://wordpress.org/support/users/bensji/)
 * (@bensji)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/custom-post-type-not-saving/)
 * Hi,
 * I have several meta boxes on different pages. I all call them in 1 plugin called
   GidsenWG. The meta boxes on the ‘pages’ work fine. But the ones in the Custom
   Post Types don’t save to the DB. It all worked before the last update.
 *     ```
       <?php
       /*
       Plugin Name: GidsenWG
       Description: Make a plug-in that will display gidsItems
       Version: 1.0
       Author: Benjamin lierman
       Author URI: www.keidigiaal.be
       */
   
       function gidsenWG() {
           $labels = array(
               'name'               => _x( 'Gidsenitems', 'post type general name' ),
               'singular_name'      => _x( 'Gidsitem', 'post type singular name' ),
               'add_new'            => _x( 'Add New', 'Gidsitem' ),
               'add_new_item'       => __( 'Nieuwe gidsitem' ),
               'edit_item'          => __( 'Edit gidsitem' ),
               'new_item'           => __( 'Nieuw gidsitem' ),
               'all_items'          => __( 'Alle gidsitems' ),
               'view_item'          => __( 'Toon gidsitem' ),
               'search_items'       => __( 'Zoek gidsitems' ),
               'not_found'          => __( 'No gidsitem found' ),
               'not_found_in_trash' => __( 'No gidsitem found in the Trash' ),
               'parent_item_colon'  => '',
               'menu_name'          => 'Gidsitems'
           );
           $args = array(
               'labels'        => $labels,
               'description'   => 'Dit zijn alle Gidsitems',
               'public'        => true,
               'menu_position' => 10,
               'supports'      => array( 'title', 'editor', 'thumbnail'),
               'has_archive'   => true
           );
           register_post_type( 'gidsenWG', $args );
           flush_rewrite_rules( false );
       }
       add_action( 'init', 'gidsenWG', 0 );
   
       add_filter( 'rwmb_meta_boxes', 'westgids_register_meta_boxes' );
       function westgids_register_meta_boxes( $meta_boxes )
       {
           $prefix = 'westgids';
   
       // 1st meta box
           $meta_boxes[] = array(
               'id'       => 'serie01',
               'title'    => __( 'De header van de pagina', 'westgids' ),
               'post_types'    => array( 'page' ),
               'context'  => 'normal',
               'priority' => 'high',
               'fields' => array(
               // TEXTAREA
                   array(
                       'name'  => __( 'Titel', 'westgids' ),
                       'id'    => $prefix . '_titel',
                       'desc'  => __( 'Dit is de titel van de pagina. bv Kijken naar Geschiedenis', 'westgids' ),
                       'type'  => 'text',
                       // CLONES: Add to make the field cloneable (i.e. have multiple value)
                       'clone' => false
                   ),
                   // TEXTAREA
                   array(
                       'name' => __( 'Ondertitel', 'westgids' ),
                       'desc' => __( 'En dit is dan de ondertitel. Hier kun je meer informatie erover geven.', 'westgids' ),
                       'id'   => $prefix . '_ondertitel',
                       'type' => 'textarea',
                       'cols' => 20,
                       'rows' => 10
                   )
           )
       );
   
           // 1st meta box
           $meta_boxes[] = array(
               'id'       => 'serie02',
               'title'    => __('De button onder het element', 'westgids'),
               'post_types'    => array( 'lezingenWG', 'gidsenWG', 'FrontPageWG' ),
               'context'  => 'normal',
               'priority' => 'high',
               'fields' => array(
                   array(
                       'name'  => __( 'Knoptekst', 'westgids' ),
                       'id'    => $prefix . '_knoptekst',
                       'desc'  => __( 'Dit is de tekst in de knop van de pagina. bv Reserveer nu', 'westgids' ),
                       'type'  => 'text',
                       // CLONES: Add to make the field cloneable (i.e. have multiple value)
                       'clone' => false
                   )
               )
           );
   
           // 1st meta box
           $meta_boxes[] = array(
               'id'       => 'serie03',
               'title'    => __('De 2 elementen op de voorpagina.', 'westgids'),
               'post_types'    => array( 'FrontPageWG' ),
               'context'  => 'normal',
               'priority' => 'high',
               'fields' => array(
                   array(
                       'name'  => __( 'titel01 (boven het lijntje)', 'westgids' ),
                       'id'    => $prefix . '_FP01tekst',
                       'desc'  => __( 'Dit is de tekst die boven het lijntje zal komen.', 'westgids' ),
                       'type'  => 'text',
                       // CLONES: Add to make the field cloneable (i.e. have multiple value)
                       'clone' => false
                   ),
                   array(
                       'name'  => __( 'titel02', 'westgids' ),
                       'id'    => $prefix . '_FP02tekst',
                       'desc'  => __( 'Dit is gewone titel (zoals je overal anders hebt)', 'westgids' ),
                       'type'  => 'text',
                       // CLONES: Add to make the field cloneable (i.e. have multiple value)
                       'clone' => false
                   ),
                   // URL
                   array(
                       'name'  => __( 'URL', 'westgids' ),
                       'id'    => $prefix. '_buttonUrl',
                       'desc'  => __( 'URL description idvm http://google.com', 'westgids' ),
                       'type'  => 'url'
                   )
               )
           );
           return $meta_boxes;
       }
       ```
   
 * In the front:
 *     ```
       <?php
       /*
       Template Name: Lezingen (Tekst Bovenaan, 3-columns onderaan)
       */
       ?>
   
       <?php get_header(); ?>
   
       <div id="main-container">
           <main id="main" role="main" class="clearfix">
   
               <div id="headerPage">
                   <h1 class="titel">
                       <?php echo rwmb_meta('westgids_titel'); ?>
                   </h1>
                   <p>
                       <?php echo rwmb_meta('westgids_ondertitel'); ?>
                   </p>
               </div>
   
               <div id="apartePaginaHomeLinks">
               <?php $args = array( 'post_type' => 'LezingenWG', 'order' => 'ASC' );
               $loop = new WP_Query( $args ); ?>
               <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
                   <article class="small-12 large-4 columns homeLinks left end pageItem clearfix">
                       <h2><?php the_title(); ?></h2>
                       <div class="itemPhoto" style="<?php
   
                       $url = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
                       if(has_post_thumbnail()){
                           echo 'background: url('.$url.') no-repeat center center; background-size:cover';
                       } else {
                           echo "display:none";
                       }
                       ?>"></div>
                       <?php the_content(); ?>
                       <a href="http://westgids.be/contact?onderwerp=<?php the_title(); ?>"><button>
                       <p>
                           <?php echo rwmb_meta('westgids_knoptekst'); ?>
                       </p>
                       </button></a>
                   </article>
               <?php endwhile; ?>
               </div>
   
           </main>
       </div>
   
       <?php get_footer(); ?>
       ```
   
 * [https://wordpress.org/plugins/meta-box/](https://wordpress.org/plugins/meta-box/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [Bensji](https://wordpress.org/support/users/bensji/)
 * (@bensji)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/custom-post-type-not-saving/#post-6913142)
 * I solved it.
 * I just had to delete all the capitals in the Custom Post Type Names. Is this 
   some sort of change? Before the udpate everything worked fine!
 * Thank you
 *  [PeterIbsen](https://wordpress.org/support/users/peteribsen/)
 * (@peteribsen)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/custom-post-type-not-saving/#post-6913439)
 * I had the same problem – thanks for posting the solution!
 *  [vvivianne](https://wordpress.org/support/users/vvivianne/)
 * (@vvivianne)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/custom-post-type-not-saving/#post-6913443)
 * I have the same problem.
    And it´s not a real solution to change the capital 
   letters in the title of the custom post types. Is there a final solution to this
   problem from the developer, please?
 *  Plugin Author [Anh Tran](https://wordpress.org/support/users/rilwis/)
 * (@rilwis)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/custom-post-type-not-saving/#post-6913444)
 * Hi,
 * When you register a new post type (‘ABCxyz’ for example), WP auto sanitises (
   remove special chars, make it lowercase) the post type name (to ‘abcxyz’) and
   uses that as the ID of the post type.
 * When saving the post, WP fires a hook “save_post_{$post_type}” which is used 
   by Meta Box and it requires the post type to be in lower case.
 * Previously we use “save_post” hook which is more general, but it causes some 
   potential problems as reported here [https://github.com/rilwis/meta-box/issues/650](https://github.com/rilwis/meta-box/issues/650)

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Custom Post Type not saving’ is closed to new replies.

 * ![](https://ps.w.org/meta-box/assets/icon-128x128.png?rev=1100915)
 * [Meta Box](https://wordpress.org/plugins/meta-box/)
 * [Support Threads](https://wordpress.org/support/plugin/meta-box/)
 * [Active Topics](https://wordpress.org/support/plugin/meta-box/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/meta-box/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/meta-box/reviews/)

 * 4 replies
 * 4 participants
 * Last reply from: [Anh Tran](https://wordpress.org/support/users/rilwis/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/custom-post-type-not-saving/#post-6913444)
 * Status: resolved