How to edit Custom Type

Updated: October 20, 2013, 9:56 am

(example for WP Directory Item type)

Following tutorial shows how to add few simple fields into your Item custom type in Directory theme (basically steps to edit other custom types in other themes are very similar…).

Adding additional information for some custom type require:
1. Modify backend where you can store information for custom type.
2. Modify frontend codes to show these new information on your site.

1. Modify backend – settings of custom type

In our themes structure of settings in admin area is saved in files with extension *.neon
Neon files you can find in theme folder ./wp-content/themes/themeName/config – there are files with settings structures as AIT General Settings and AIT Appearance (these settings are in file theme-config.neon)
Neon files for custom types are in folders of each custom type: ./wp-content/themes/themeName/AIT/Framework/CustomTypes/folderOfCustomType

For example for custom type Item in Directory theme, is structure of settings in file ./wp-content/themes/directory/AIT/Framework/CustomTypes/dir-item/dir-item.neon

Following image shows how the structure looks. For example Opening Hours in Item custom type:

Let’s try add some additional information for this Item custom type, for example some information about contact person for this Item.
We’ll create new section with name Contact Person, and for each Item we will be able store information:
1. contact person name
2. contact person phone
3. some additional information for this contact person.

Following structure of Opening Hours section, we can create something like that:

"Contact Person" : section
contactPersonName:
	label: Name
	type: text
contactPersonPhone:
	label: Phone
	type: text
contactPersonInfo:
	label: Additional Info
	type: textarea

Following image shows what is the result of these few lines:

Now we can store for each Item custom type new information.
We’ll need now edit frontend code to show new information on site.

2. Modify frontend – show information on site

Template files with main html codes for site are in folder “Templates” (./wp-content/themes/themeName/Templates).
In this example we want show new information on the single page of Item custom type – for this page is used file ./wp-content/themes/directory/Templates/single-ait-dir-item.php

Following image shows which code represent section with Opening Hours.

We are using Nette framework in our themes, more information about Nette Framework here: http://doc.nette.org/en/

Opening Hours are inside “if” condition to do not show items which are not filled for current Item custom type.

Similar we can show new section with Contact Person information for example below Opening Hours:

And this is result of changes above: