library wp-post-type
Custom Post Type utility for WordPress.
hanamura/wp-post-type
Custom Post Type utility for WordPress.
- Tuesday, October 7, 2014
- by hanamura
- Repository
- 1 Watchers
- 0 Stars
- 1,065 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 4 Versions
- 5 % Grown
wp-post-type
Custom Post Type utility for WordPress., (*1)
Example
array('title', 'editor'),
'has_archive' => true
));
}
// compose edit screen
public function onAddMetaBoxes()
{
// create 'Info' box
add_meta_box(
'my-post-type-info',
'Info',
array($this, 'addMetaInfo'),
$this->name
);
}
public function addMetaInfo($post)
{
// input tags for custom fields: 'nickname' and 'birth_year'
?>
<p>
Nickname<br>
<input type="text" name="nickname" value="<?php echo esc_attr($post->nickname) ?>"></input><br>
</p>
<p>
Birth Year<br>
<input type="number" name="birth_year" value="<?php echo esc_attr($post->birth_year) ?>"></input>
</p>
<?php
}
public function onCheckedSavePost($post_id, $post)
{
$params = stripslashes_deep($_POST);
// save custom values in a custom way
if (isset($params['nickname'])) {
$value = trim($params['nickname']);
update_post_meta($post_id, 'nickname', $value);
}
if (isset($params['birth_year'])) {
$value = intval($params['birth_year']);
update_post_meta($post_id, 'birth_year', $value);
}
}
}
// register 'my-post-type'
new MyPostType();
dev-master
9999999-dev
Custom Post Type utility for WordPress.
Sources
Download
MIT
The Requires
by
Taro Hanamura
1.1.0
1.1.0.0
Custom Post Type utility for WordPress.
Sources
Download
MIT
The Requires
by
Taro Hanamura
1.0.1
1.0.1.0
Custom Post Type utility for WordPress.
Sources
Download
MIT
The Requires
by
Taro Hanamura
1.0.0
1.0.0.0
Custom Post Type utility for WordPress.
Sources
Download
MIT
The Requires
by
Taro Hanamura