Tagged: ,

Viewing 4 reply threads
  • Author
    Posts
    • #3772
      vagelis
      Member

      I have been working on my first plugin with Piklist. I’ve created a custom post type named ‘service’, along with a meta box named ‘test’ with additional fields. I’ve checked all headers and they seem correct. Folder structure seems also correct. Plugin works correctly btw. Please advise what I’m doing wrong. I’ve attached both post-type code and meta-box code.

    • #3773
      vagelis
      Member

      Plugin Code:

      <?php
      /*
      Plugin Name: Services
      Description: Piklist Plugin for Services
      Version: 0.1
      Author: Vagelis Katsiotis
      Author URI: https://gr.linkedin.com/in/vageliskatsiotis
      Plugin Type: Piklist
      License: GPL3
      */
      
      
      function services_post_types($post_types) {
      
      $post_types['services'] = array(
            'labels' 			=> piklist('post_type_labels', 'Services')
            ,'title' 			=> __('Add a new Service')
      
            ,'supports' 		=> array(
              'title',
              'revisions',
            )
            ,'public' 		=> true
      
            ,'taxonomies'		=> array('category')
      
            ,'has_archive'	=> true
            ,'rewrite' 		=> array(
              'slug' 			=> 'service'
            )
            ,'edit_columns' 	=> array(
              'title' 		=> __('Service')
      		,'post_states' 	=> __('Status')
            )
            ,'hide_meta_box' 	=> array(
              'slug'
              ,'author'
            )
            ,'post_states' 	=> true
            ,'status' 		=> array(
              'draft' 		=> array(
                'label' 		=> 'Inactive'
                ,'public' 	=> true
              )
              ,'active' 		=> array(
                'label' 		=> 'Active'
                ,'public' 	=> true
              )
            )
          );
      
          return $post_types;
      }
      
      add_filter('piklist_post_types', 'services_post_types');
      

      Meta-Box Code:

      <?php
      /*
      Title: Test
      Description: Test metabox
      Post Type: service, post, page
      Context: normal
      Priority: high
      Order: none
      Locked: false
      New: true
      Status: all
      Collapse: true
      */
      
      piklist('field', array(
      	'type' => 'colorpicker'
      	,'scope' => 'post_meta' // Not used for settings sections
      	,'field' => 'field_name'
      	,'label' => 'Example Field'
      	,'description' => 'Click in box'
      	,'attributes' => array(
      	'class' => 'text'
      	)
      ));
      
    • #3774
      Steve
      Keymaster

      @vagelis– You’re so close!

      A few issues with your parameters:
      1) Post Type: services, post, page: you had it set to service (singular), but your post type is plural.
      2) New: true: remove. You really only need if setting to false.
      3) Status: all: all is not a valid status. You would either have to type all the statuses here, or just remove this.
      4) Order: none: if you don’t want to set the order, then just leave this out.

      You comment block should look like this:

      /*
      Title: Test
      Description: Test metabox
      Post Type: services, post, page
      Context: normal
      Priority: high
      Locked: false
      Collapse: true
      */
      

      Let us know if you have any other questions.

    • #3778
      vagelis
      Member

      Thank you for your help Steve. Worked like a charm!

    • #3779
      Steve
      Keymaster

      Great. Closing ticket.

Viewing 4 reply threads
  • The topic ‘Meta Box Not Showing’ is closed to new replies.