Skip to content

Instantly share code, notes, and snippets.

@horne3754sg
Last active August 29, 2015 14:06
Show Gist options
  • Save horne3754sg/26805f4065c67efb9ab7 to your computer and use it in GitHub Desktop.
Save horne3754sg/26805f4065c67efb9ab7 to your computer and use it in GitHub Desktop.
An example Thesis 2 box demonstrating how to register a Custom Post Type (CPT) within boxes.
<?php
/*
Name: Example CPT registration in a Thesis 2 Box
Author: Matthew Horne - Zerogravityskins.com
Description: enter your description here.
Version: 1.0
Class: my_custom_class
*/
class my_custom_class extends thesis_box {
protected function translate() {
$this->name = __('Example CPT registration in a Thesis 2 Box', $this->_class);
}
protected function construct() {
// since the action hoiok is called after the register post type hook
// you will need to simply call your function like so.
$this->faq_custom_init();
}
protected function html_options() { // basic HTML options add more if necessary
global $thesis;
$html = $thesis->api->html_options();
unset($html['id']);
return $html;
}
public function faq_custom_init() { // example FAQ post type
$labels = array(
'name' => 'FAQ',
'singular_name' => 'FAQ',
'add_new' => 'Add New FAQ',
'add_new_item' => 'Add New FAQ',
'edit_item' => 'Edit FAQ',
'new_item' => 'New FAQ',
'all_items' => 'All FAQ',
'view_item' => 'View FAQ',
'search_items' => 'Search FAQ',
'not_found' => 'No FAQ found',
'not_found_in_trash' => 'No FAQ found in Trash',
'parent_item_colon' => '',
'menu_name' => 'FAQ',
);
$args = array(
'labels' => $labels,
'exclude_from_search' => false,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'FAQ' ),
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'taxonomies' => array('category'),
'menu_position' => null,
'supports' => array( 'title', 'author', 'thumbnail', 'excerpt', 'editor' )
);
register_post_type( 'faq', $args );
}
public function html($args = array()) {
global $thesis;
extract($args = is_array($args) ? $args : array());
$tab = str_repeat("\t", !empty($depth) ? $depth : 0);
// your output goes below here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment