• Resolved solokco

    (@solokco)


    I have a plugin that I would like to migrate to MVC using this plugin.

    I followed the instructions on the documentation to create a CPT but I’m not clear on how to show the DEFAULT TEMPLATE (admin area) that WordPress shows when a CPT is created.

    Can you guide me with this please.

    Here is the code in my old Plugin to create a CPT:

    public function registrar_cpt_servicios()  {
    		
    		$servicio_labels = array(
    			'name'               => _x( 'Servicios', 'post type general name', 'estilotu' ),
    			'singular_name'      => _x( 'Servicio', 'post type singular name', 'estilotu' ),
    			'menu_name'          => _x( 'Servicios', 'admin menu', 'estilotu' ),
    			'name_admin_bar'     => _x( 'Servicio', 'add new on admin bar', 'estilotu' ),
    			'add_new'            => _x( 'Nuevo servicio', 'book', 'estilotu' ),
    			'add_new_item'       => __( 'Agregar nuevo servicio', 'estilotu' ),
    			'new_item'           => __( 'Nuevo servicio', 'estilotu' ),
    			'edit_item'          => __( 'Editar servicio', 'estilotu' ),
    			'view_item'          => __( 'Ver servicios', 'estilotu' ),
    			'all_items'          => __( 'Todos los Servicios', 'estilotu' ),
    			'search_items'       => __( 'Buscar servicios', 'estilotu' ),
    			'parent_item_colon'  => __( 'Servicios padres:', 'estilotu' ),
    			'not_found'          => __( 'No se encontraron servicios.', 'estilotu' ),
    			'not_found_in_trash' => __( 'No se encontraron servicios en la papelera.', 'estilotu' )
    		);
    		
    		$args = array(
    			'labels' 				=> $servicio_labels,
    			'description' 			=> __( 'Servicios que ofrece un proveedor de Servicios.', 'estilotu' ),
    			'public' 				=> true,
    			'publicly_queryable'	=> true,
    			'rewrite'            	=> array( 'slug' => 'servicios' ),
    			'capability_type' 		=> 'post',
    			'show_in_menu'       	=> true,
    			'menu_position' 		=> 5,
    			'hierarchical' 			=> false,
    			'supports' 				=> array('title','editor','author','thumbnail','excerpt','comments','custom-fields'),
    			'has_archive'			=> true,
    			'capability_type' 		=> 'post'
    			); 
    		
    		register_post_type('servicios', $args);
    	}

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Robert Peake

    (@robertpeake)

    While wp-mvc supports mirroring model data with custom posts, I generally don’t use that functionality but instead favour using the public and admin controllers to display data via views.

    If you need a custom data type that is very similar to a page or post, custom post types are a good approach. If you need a lot of other custom fields and/or complex join relationships between objects, wp-mvc will help you do that much more quickly and elegantly.

    Hope that helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Creating a CPT (custom post type)’ is closed to new replies.