Documentation of the KickPress plugin.

Extend the KickPress API with Modules

Description

Extend your newly created custom post type by adding custom fields
Custom fields can be assigned to your custom post types as “attributes” or form fields for content entry.  These custom attributes are what make your newly created post type unique, in the case of “People” there might be a “First Name”, “Middle Name” and “Last Name” which help describe a person.

In our example above of a post type called “People” you will need to create a file called “class-people.php”, the naming convention for these files is “class-{custom post type slug}.php”

Below is a code sample for a “module” called “People” with custom fields or “Attributes”

Source code    
<?php
 
class kickpress_people extends kickpress_api {
 
	public function get_custom_fields ($args) {
 
		$custom_fields = array(
			'first_name'=>array(
				'name'=>'_first_name',
				'notnull'=>true
			),
			'middle_name'=>array(
				'name'=>'_middle_name'
			),
			'last_name'=>array(
				'name'=>'_last_name',
				'notnull'=>true
			)
		);
 
		return $custom_fields;
	}
}
 
?>

And now for uploading your newly created module to your site, either create a folder called “modules” in your theme directory or use the “modules” directory in the KickPress plugin directory.  Either way will work, but each has a different scope within your WordPress install.

Global scope modules for WordPress multisite installs:
Adding custom class files to KickPress’ “modules” directory in a multisite environment makes your custom class accessible to all sites that have KickPress installed as a plugin
/wp-content/plugins/kickpress/modules/class-{your custom post type slug}.php

Local scope modules for use within a single theme:
Adding custom class files to the “modules” directory of your theme makes the class accessible only to that theme.  Class files added to the local theme’s modules directory by the same name as class files in the plugins class directory take precedence over the plugin’s class files.
/wp-content/themes/{your theme name}/modules/class-{your custom post type slug}.php
Add the “class-people.php” to the “modules” directory in your theme.

Comments are closed.