}
            }
            break;
        case 'slug':
            $text = basename(get_post_permalink($id));
            echo $text;
            break;
        default:
            break;
    }
    // end switch
}
/*custom admin columns for custom post type taxonomies*/
add_filter('manage_edit-portfolio-category_columns', 'oblivion_portfolio_category_columns', 2);
add_action('manage_portfolio-category_custom_column', 'oblivion_portfolio_category_custom_columns', 2, 3);
function oblivion_portfolio_category_columns($defaults)
{
    $defaults['portfolio-category_ids'] = __('Category ID', 'oblivion');
    return $defaults;
}
function oblivion_portfolio_category_custom_columns($value, $column_name, $id)
{
    if ($column_name == 'portfolio-category_ids') {
        return (int) $id;
    }
}
/*add smartmetaboxes*/
add_action('add_meta_boxes', 'oblivion_my_custom_box');
add_action('save_post', 'saving_my_data');
function oblivion_my_custom_box()
{
示例#2
0
            </div>
<?php 
}
/*Produces an avatar image with the hCard-compliant photo class*/
function crystalskull_commenter_link()
{
    $commenter = get_comment_author_link();
    if (preg_match('/<a[^>]* class=[^>]+>/', $commenter)) {
        $commenter = preg_replace('/(<a[^>]* class=[\'"]?)/', '\\1url ', $commenter);
    } else {
        $commenter = preg_replace('/(<a )/', '\\1class="url "/', $commenter);
    }
    echo ' <span class="comment-info">' . $commenter . '</span>';
}
/*add smartmetaboxes*/
add_smart_meta_box('my-meta-box9', array('title' => esc_html__('Slider shortcode (works with "Homepage" template only)', 'crystalskull'), 'pages' => array('page'), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('name' => esc_html__('Paste your slider shortcode here.', 'crystalskull'), 'id' => 'slider_short', 'type' => 'textarea', 'default' => ''))));
function crystalskull_wp_editor($post)
{
    $field_value = get_post_meta($post->ID, '_smartmeta_my-awesome-field', false);
    if (!isset($field_value[0])) {
        wp_editor('', '_smartmeta_my-awesome-field');
    } else {
        wp_editor($field_value[0], '_smartmeta_my-awesome-field');
    }
}
function crystalskull_saving_my_data($post_id)
{
    if (isset($_POST['_smartmeta_my-awesome-field'])) {
        update_post_meta($post_id, '_smartmeta_my-awesome-field', $_POST['_smartmeta_my-awesome-field']);
    }
}