Translations of this page:

Post types

Post Types are the base of Magic Fields, in this section we'll see how to create a Post Type and which are it's options and characteristics.

To create a Post Type click on the link from the menu Magic Fields → Magic Fields

This will show us the Post Types and Custom Taxonomies dashboard in the Post Types section and will show us all the Post Types that are registered in the system regardless if they were created with Magic Fields or not. This is a great characteristic because we can add an existing Post Types Custom Field like a Post, page or a Post Types added by other plugins or by a code that was already there.

Post Types that weren't created with Magic Fields can't be edited with Magic Fields for obvious reasons. We can only add Custom Fields and Groups. A menu for that Post Type is showed when the mouse pointer is on the field's label.

Post Type created with con Magic Fields

Post Type not created with Magic Fields.

 


 

Create a Post Type

To create a Post Type in the Post Type dashboard there is a button called “Add a new Post Type” click on it and it will take us to the form to the add a Post Type form.

Inside this form there are 3 sections

  • General information
  • Advanced options
  • Advanced label

General information

In this section we will find the Post Type data, the label and type fields are mandatory. Here is a detail for each field in this section.

  • Type : a string that only accepts numbers, letters and underscores, this will be key for the post type. This will be the name registered in Wordpress.
  • Label : A singular descriptive name for the Post Type.
  • Labels : A plural descriptive name for the Post Type.
  • Description: A brief description of the Post Type.
  • Supports : In this part we can chose what type of support the Post Type will have, if we leave everything unchecked for the Post Type Wordpress will add the support 'title' and 'content' as a default.
  • Taxonomies : We can chose which taxonomies the Post Type will be able to access.

When we save the changes Magic Fields will check that the required fields are not left blank and that the “Type” is unique, if this is not the case and the “Type” is already being used it will show a message.

Advanced options

In the advanced options of the Post Type each option has an explanation. If you wish to know more about each option please visit the register_post_type section in the codex.

In this section we have to be careful with these options:

“Capability type” this field indicates the capabilities that the Post Type will have, the most common are “post” or “page” but we can enter a different string to this new capability for the administrator and we will have to add the different capabilities for the other roles. For more information read Roles and Capabilities and the “capabilities” section of Function Reference/register post type.

“Rewrite” and “Rewrite slug” if we chose to re-write the url for the Post Type make sure that you flush all the re-write rules (inside the Permalink section and save them again) more information here Custom Post Type and Permalink.

Advanced label

In this section we will assign texts for each Post Type section. In the upper part there is a checkbox marked as “Suggest Labels” if this checkbox is selected it will give us suggestions for each label, basing the suggestions on the field label in the general options. Watch this video of the behavior.

 


 

Edit a Post Type

To edit a Post Type just click on “Edit Post Type” in the dashboard. The form to edit the Post Type is the same used to create it. If you have any doubts please go back to the previous section.

 


 

Erase a Post Type

When you erase a Post Type the reference to the Post Type in Magic Fields will be deleted. The Custom fields and the groups related will also be deleted. The elements created with that Post Type will still be kept in the Wordpress tables.

 


 

Importing and Exporting a Post Type

If we need to duplicate a Post Type you can use the Export in the Post Type. You need to go in the “Edit Fields/Groups” link for the Post Type.

Inside the Custom Fields dashboard found in the upper left hand corner next to the Post Type name we will find the “Export” link.

This will download a {type of post type}.pnl file which contains all the information related to the Post Type, it's Custom Fields, groups and Custom Taxonomies.

To import the Post Type we click on “Import” in the Magic Fields menu.

This link will take us to the page where we will look for the file we want to import. This form has an option that affects the importing process. This option is “Overwrite”, if “Overwrite” is selected and the Post Type exists in the system it will overwrite the Post Types otherwise it will create a new Post Type.

 


 

Using a Post Type

Once we create the Post Type we can see a section for it in the menu.

In this section we have the element administrator, in this case “Review”, this administrator is just like the one we used with Post Types “Post” or “Page”. The elements showed depend on the support that we assigned to the Post Type.

When we create or edit an element of the Post Type we'll see all the elements related to the Post Type (supports elements, groups/custom fields, taxonomies, etc).

post_types_v20.txt · Last modified: 2011/07/29 18:39 by bcorona