Adding Custom Post Type & Taxonomy to Widget Options
The way that I got Widget Options to work for my custom post type "treatments" and to show all the terms under by custom taxonomy "conditions" was to modify some system files (hopefully at some point these files can be moved into the theme or my custom style).
First I added my code to the display.php file found in warp --> systems --> wordpress --> config --> layouts --> fields

Here is the code in my display.php file:
<?php
/**
* @package Warp Theme Framework
* @author YOOtheme http://www.yootheme.com
* @copyright Copyright (C) YOOtheme GmbH
* @license http://www.gnu.org/licenses/gpl.html GNU/GPL
*/
$options = array();
$defaults = array(
'*' => 'All',
'front_page' => 'Frontpage',
'home' => 'Home (Posts page)',
'archive-treatments' => 'Treatments Archives',
'taxonomy-conditions' => 'Conditions Archives',
'archive' => 'Archive',
'search' => 'Search',
'single' => 'Single',
'single-treatments' => 'Treatments Single',
'page' => 'Pages',
);
$selected = is_array($value) ? $value : array('*');
if (count($selected) > 1 && in_array('*', $selected)) {
$selected = array('*');
}
// set default options
foreach ($defaults as $val => $label) {
$attributes = in_array($val, $selected) ? array('value' => $val, 'selected' => 'selected') : array('value' => $val);
$options[] = sprintf('<option %s />%s</option>', $control->attributes($attributes), $label);
}
// set pages
if ($pages = get_pages()) {
$options[] = '<optgroup label="Pages">';
foreach ($pages as $page) {
$val = 'page-'.$page->ID;
$attributes = in_array($val, $selected) ? array('value' => $val, 'selected' => 'selected') : array('value' => $val);
$options[] = sprintf('<option %s />%s</option>', $control->attributes($attributes), $page->post_title);
}
$options[] = '</optgroup>';
}
// set categories
if ($categories = get_categories()) {
$options[] = '<optgroup label="Categories">';
foreach ($categories as $category) {
$val = 'cat-'.$category->cat_ID;
$attributes = in_array($val, $selected) ? array('value' => $val, 'selected' => 'selected') : array('value' => $val);
$options[] = sprintf('<option %s />%s</option>', $control->attributes($attributes), $category->cat_name);
}
$options[] = '</optgroup>';
}
// set conditions
if ($terms = get_terms('conditions')) {
$options[] = '<optgroup label="Conditions">';
foreach ( $terms as $term ) {
$val = 'tax-'.$term->slug;
$attributes = in_array($val, $selected) ? array('value' => $val, 'selected' => 'selected') : array('value' => $val);
$options[] = sprintf('<option %s />%s</option>', $control->attributes($attributes), $term->name);
}
$options[] = '</optgroup>';
}
?>
<select name="<?php echo $name;?>[]" style="width:220px;height:120px;" multiple="multiple">
<?php echo implode("", $options); ?>
</select>
Next I modified system.php in warp --> systems --> wordpress --> helpers. This is my code.
/*
Function: getQuery
Get current query information
Returns:
Object
*/
public function getQuery() {
global $wp_query;
// create, if not set
if (empty($this->query)) {
// init vars
$obj = $wp_query->get_queried_object();
$query = array();
// find current page type
foreach (array('home', 'front_page', 'archive', 'taxonomy-conditions', 'archive-treatments', 'single-treatments', 'search', 'single', 'page', 'category', 'conditions') as $type) {
if (call_user_func('is_'.$type)) {
$query[] = $type;
if ((is_single()) && (get_post_type() == 'treatments')) {
$query[] = 'single-treatments';
}
if ((is_archive()) && get_taxonomy( 'conditions')) {
$query[] = 'taxonomy-conditions';
}
if ((is_archive()) && is_post_type_archive( 'treatments')) {
$query[] = 'archive-treatments';
}
if ($type == 'page') {
$query[] = 'page-'.$obj->ID;
}
if ($type == 'category') {
$query[] = 'cat-'.$obj->cat_ID;
}
if (is_tax( 'conditions')){
$query[] = 'tax-'.$obj->slug;
}
}
}
$this->query = $query;
}
return $this->query;
}
The end result is that I have widget options for my templates as well as all the terms in the custom taxonomy "conditions."
Again, I hope this helps.
