Jimmylet
11/15/2018 - 2:43 PM

register-gallery-post-type.php

Register new gallery post type as a mu-plugin

<?php
/*
 * this file is mu-plugins/gallery-post-type.php
 *
 * Plugin Name: Register Gallery Post Type
 * Plugin URI: http://knok.be/
 * Description: Register a new custom post type for create galleries
 * Version: 1.0
 * Author: Knok Design
 * Author URI: http://knok.be
*/

if ( !post_type_exists( 'gallery' ) ) {
  function register_gallery_type() {
    $label_singular = 'Galerie';
    $label_plural   = 'Galeries';
    register_post_type(
      'gallery',
      array(
        'label'           => $label_plural,
        'description'     => '',
        'public'          => true,
        'show_ui'         => true,
        'show_in_menu'    => true,
        //'menu_position'       => 12,
        'menu_icon'           => 'dashicons-format-gallery',
        'capability_type' => 'post',
        'hierarchical'    => false,
        'query_var'       => true,
        'has_archive'     => true,
        'rewrite' => array(
          'slug'       => pll__('galeries'),
          'with_front' => false,
        ),
        'supports' => array(
          'title',
          'editor',
          'revisions',
          'thumbnail',
          'custom-fields',
        ),
        'labels' => array (
          'name'               => $label_plural,
          'singular_name'      => $label_singular,
          'menu_name'          => $label_plural,
          'add_new'            => 'Ajouter nouvelle',
          'add_new_item'       => 'Ajouter nouvelle ' . $label_singular,
          'edit'               => 'Modifier',
          'edit_item'          => 'Modifier ' . $label_singular,
          'new_item'           => 'Nouvelle ' . $label_singular,
          'view'               => 'Voir la ' . $label_singular,
          'view_item'          => 'Voir la ' . $label_singular,
          'search_items'       => 'Rechercher unr ' . $label_plural,
          'not_found'          => 'Pas de ' . $label_plural . ' trouvées',
          'not_found_in_trash' => 'Pas de ' . $label_plural . ' trouvées dans la corbeille',
          'parent'             => 'Parent ' . $label_singular,
        )
      )
    );
  }
  add_action('init', 'register_gallery_type');
}