true, "label" => "Portfolio Categories", "singular_label" => "Portfolio Categories", "rewrite" => true, "query_var" => true )); } /** * Registers the portfolio custom type. */ function pexeto_register_portfolio_post_type() { //the labels that will be used for the portfolio items $labels = array( 'name' => _x('Portfolio', 'portfolio name'), 'singular_name' => _x('Portfolio Item', 'portfolio type singular name'), 'add_new' => _x('Add New', 'portfolio'), 'add_new_item' => __('Add New Item'), 'edit_item' => __('Edit Item'), 'new_item' => __('New Portfolio Item'), 'view_item' => __('View Item'), 'search_items' => __('Search Portfolio Items'), 'not_found' => __('No portfolio items found'), 'not_found_in_trash' => __('No portfolio items found in Trash'), 'parent_item_colon' => '' ); //register the custom post type register_post_type( PEXETO_PORTFOLIO_POST_TYPE, array( 'labels' => $labels, 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('slug'=>'portfolio'), 'taxonomies' => array('portfolio_category', 'post_tag'), 'supports' => array('title', 'editor', 'thumbnail', 'comments', 'page-attributes') ) ); } function portfolio_columns($columns) { $columns['category'] = 'Portfolio Category'; return $columns; } /** * Add category column to the portfolio items page * @param $name */ function portfolio_show_columns($name) { global $post; switch ($name) { case 'category': $cats = get_the_term_list( $post->ID, 'portfolio_category', '', ', ', '' ); echo $cats; } } /** * Gets a list of custom taxomomies by slug * @param $term_id the slug */ function pexeto_get_taxonomy_slug($term_id){ global $wpdb; $res = $wpdb->get_results($wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE term_id=%s LIMIT 1;", $term_id)); $res=$res[0]; return $res->slug; } /** * Builds the HTML code for a single portfolio item image - can be used in plugins or * other widgets that display a set of portfolio items * @param $post_id the ID of the post * @param $width the width that will be set to the image * @param $height the height that will be set to the image */ function pexeto_build_portfolio_image_html($post, $width, $height, $showTitle=false, $groupName='group'){ $post_id=$post->ID; $preview=get_post_meta($post_id, 'preview_value', true); $thumbnail=get_post_meta($post_id, 'thumbnail_value', true); if(!$thumbnail || $thumbnail==''){ $crop=get_post_meta($post->ID, 'crop_value', true); $thumbnail=pexeto_get_resized_image($preview, $width, $height,$crop); } $action=get_post_meta($post_id, 'action_value', true); $customlink=get_post_meta($post_id, 'custom_value', true); //set the link of the image depending on the action selected if($action=='nothing'){ $openLink=''; $closeLink=''; }else if($action=='permalink'){ $openLink=''; $closeLink=''; }else if($action=='custom'){ $openLink=''; $closeLink=''; }else{ $preview=$action=='video'?$customlink:$preview; $rel=$groupName==''?'lightbox':'lightbox['.$groupName.']'; $description=get_post_meta($post_id, 'description_value', true); $desc_title=$description?esc_attr($description):''; $openLink=''; $closeLink=''; } $title=$showTitle?'