/** * 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(); }
/** * Register post types for the theme * * @return void */ function yiw_register_post_types() { register_post_type(TYPE_TESTIMONIALS, array('description' => __('Testimonals', 'yiw'), 'exclude_from_search' => false, 'show_ui' => true, 'labels' => yiw_label(apply_filters('yiw_testimonials_label_singular', __('Testimonial', 'yiw')), apply_filters('yiw_testimonials_label_plural', __('Testimonials', 'yiw'))), 'supports' => array('title', 'editor', 'thumbnail', 'excerpt'), 'public' => true, 'show_in_nav_menus' => false, 'capability_type' => 'post', 'publicly_queryable' => true, 'rewrite' => array('slug' => apply_filters('yiw_testimonial_rewrite', 'post/testimonials'), 'with_front' => true))); register_post_type(TYPE_FAQ, array('description' => __('Faq', 'yiw'), 'exclude_from_search' => false, 'show_ui' => true, 'labels' => yiw_label(__('Faq', 'yiw'), __('Faqs', 'yiw')), 'supports' => array('title', 'editor', 'revisions'), 'public' => true, 'show_in_nav_menus' => false, 'capability_type' => 'page', 'publicly_queryable' => true, 'rewrite' => array('slug' => apply_filters('yiw_faq_rewrite', TYPE_FAQ), 'with_front' => true))); register_post_type(TYPE_GALLERY, array('description' => __('Gallery', 'yiw'), 'exclude_from_search' => false, 'show_ui' => true, 'labels' => yiw_label(apply_filters('yiw_gallery_label_singular', __('Photo', 'yiw')), apply_filters('yiw_gallery_label_plural', __('Photos', 'yiw')), __('Gallery', 'yiw')), 'supports' => array('title', 'editor', 'thumbnail'), 'public' => true, 'capability_type' => 'post', 'publicly_queryable' => true, 'rewrite' => array('slug' => apply_filters('yiw_gallery_rewrite', 'post/gallery'), 'with_front' => true))); // // register_post_type( // TYPE_SERVICES, // array( // 'description' => __('Services', 'yiw'), // 'exclude_from_search' => false, // 'show_ui' => true, // 'labels' => yiw_label( apply_filters( 'yiw_services_label_singular', __('Service', 'yiw') ), apply_filters( 'yiw_services_label_plural', __('Services', 'yiw')), __('Services', 'yiw')), // 'supports' => array( 'title', 'editor', 'thumbnail' ), // 'public' => true, // 'capability_type' => 'post', // 'publicly_queryable' => true, // 'rewrite' => array( 'slug' => apply_filters( 'yiw_service_rewrite', 'post/services' ), 'with_front' => true ) // ) // ); //flush_rewrite_rules(); yiw_register_dymanics_types(); }