Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Replace hierarchial taxonomy entry with radio field
- class exmp_tax_radio_field {
- function add_theme_box() {
- add_meta_box('theme_box_ID', __('Theme'), 'your_styling_function', 'post', 'side', 'core');
- }
- function add_theme_menus() {
- if ( ! is_admin() )
- return;
- add_action('admin_menu', 'add_theme_box');
- }
- add_theme_menus();
- // This function gets called in edit-form-advanced.php
- function your_styling_function($post) {
- echo '<input type="hidden" name="taxonomy_noncename" id="taxonomy_noncename" value="' .
- wp_create_nonce( 'taxonomy_theme' ) . '" />';
- // Get all theme taxonomy terms
- $themes = get_terms('theme', 'hide_empty=0');
- ?>
- <select name='post_theme' id='post_theme'>
- <!-- Display themes as options -->
- <?php
- $names = wp_get_object_terms($post->ID, 'journal_issue');
- ?>
- <option class='theme-option' value=''
- <?php if (!count($names)) echo "selected";?>>None</option>
- <?php
- foreach ($themes as $theme) {
- if (!is_wp_error($names) && !empty($names) && !strcmp($theme->slug, $names[0]->slug))
- echo "<option class='theme-option' value='" . $theme->slug . "' selected>" . $theme->name . "</option>\n";
- else
- echo "<option class='theme-option' value='" . $theme->slug . "'>" . $theme->name . "</option>\n";
- }
- ?>
- </select>
- <?php
- }
- }
- $exmp_tax_radio_field = new exmp_tax_radio_field();
Add Comment
Please, Sign In to add comment