示例#1
0
/**
 * Register post types for the theme
 *
 * @return void
 */
function yiw_register_portoflios()
{
    register_post_type('create-portfolio', array('description' => __('Create Portfolio', 'yiw'), 'exclude_from_search' => true, 'show_ui' => true, 'labels' => yiw_label(__('Portfolio', 'yiw'), __('Portfolios', 'yiw'), __('New Portfolio', 'yiw')), 'supports' => array('title', 'thumbnail'), 'public' => false, 'menu_position' => 64));
    $portofolios = get_posts(array('post_type' => 'create-portfolio', 'numberposts' => -1));
    foreach ($portofolios as $portfolio) {
        // post types
        $rewrite = get_post_meta($portfolio->ID, '_portfolio_rewrite', true);
        $read_more = get_post_meta($portfolio->ID, '_portfolio_read_more', true);
        $label_sin = get_post_meta($portfolio->ID, '_portfolio_label_sin', true);
        $label_plu = get_post_meta($portfolio->ID, '_portfolio_label_plu', true);
        if (empty($label_sin)) {
            $label_sin = $portfolio->post_title;
        }
        if (empty($label_plu)) {
            $label_plu = $portfolio->post_title;
        }
        if (empty($rewrite)) {
            $rewrite = sanitize_title($portfolio->post_title);
        }
        // icon
        $thumbnail_id = get_post_thumbnail_id($portfolio->ID);
        if (!empty($thumbnail_id)) {
            $icon = wp_get_attachment_image_src($thumbnail_id);
        } else {
            $icon = null;
        }
        register_post_type(sanitize_title($portfolio->post_title), array('description' => apply_filters('the_title', $portfolio->post_title), 'exclude_from_search' => false, 'show_ui' => true, 'labels' => yiw_label($label_sin, $label_plu, apply_filters('the_title', $portfolio->post_title)), 'supports' => array('title', 'editor', 'thumbnail'), 'public' => true, 'capability_type' => 'page', 'publicly_queryable' => true, 'rewrite' => array('slug' => $rewrite, 'with_front' => true), 'menu_icon' => $icon));
        add_action('manage_posts_custom_column', 'yiw_portfolio_custom_columns');
        add_filter('manage_edit-' . sanitize_key($portfolio->post_title) . '_columns', 'yiw_portfolio_edit_columns');
        // taxonomies
        $portfolio_tax = get_post_meta($portfolio->ID, '_portfolio_tax', true);
        $portfolio_tax_rewrite = get_post_meta($portfolio->ID, '_portfolio_tax_rewrite', true);
        if (!empty($portfolio_tax)) {
            register_taxonomy(substr(sanitize_title($portfolio_tax), 0, 32), array(sanitize_title($portfolio->post_title)), array('hierarchical' => true, 'labels' => yiw_label_tax(__('Category', 'yiw'), __('Categories', 'yiw')), 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => $portfolio_tax_rewrite, 'with_front' => false)));
        }
    }
    //flush_rewrite_rules();
}
示例#2
0
/**
 * Registers taxonomies
 * 
 */
function yiw_register_taxonomies()
{
    register_taxonomy('category-faq', array(TYPE_FAQ), array('hierarchical' => true, 'labels' => yiw_label_tax(__('Faq Category', 'yiw'), __('Faq Categories', 'yiw')), 'show_ui' => true, 'show_in_nav_menus' => false, 'query_var' => true, 'rewrite' => array('slug' => 'faq/category', 'with_front' => false)));
    /*
    register_taxonomy('category-project', array( TYPE_PORTFOLIO ), array(
        'hierarchical' => true,
        'labels' => yiw_label_tax(__('Category', 'yiw'), __('Categories', 'yiw')),
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'project/category', 'with_front' => false )
    ));
    register_taxonomy('team-profile', array( TYPE_TEAM ), array(
        'hierarchical' => true,
        'labels' => yiw_label_tax(__('Profile', 'yiw'), __('Profiles', 'yiw')),
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'team/profile', 'with_front' => false )
    ));
    */
    register_taxonomy('category-photo', array(TYPE_GALLERY), array('hierarchical' => true, 'labels' => yiw_label_tax(__('Category', 'yiw'), __('Categories', 'yiw')), 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => apply_filters('yiw_category_photo_rewrite', 'photo/category'), 'with_front' => false)));
    register_taxonomy('category-testimonial', array(TYPE_TESTIMONIALS), array('hierarchical' => true, 'labels' => yiw_label_tax(__('Category', 'yiw'), __('Categories', 'yiw')), 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => apply_filters('yiw_category_testimonial_rewrite', 'testimonial/category'), 'with_front' => false)));
}