• I would like to create category in Portfolio, mean I have different kinds of Portfolio.

    How could I do?

    Please help me!

    Thanks! 😀

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi, please add more details! Is the portfolio custom posts types? Can’t really help without any details.

    Thanks!

    Thread Starter LSP Sopheak

    (@lsp_sopgheak)

    Thanks for your help!
    Here is the code for portfolio.php

    <?php
    /*
    Template Name: Portfolio
    */
    ?>
    <?php get_header(); ?>
    <div id=”content”>
    <?php
    $type = ‘portfolio’;
    $args=array(
    ‘post_type’ => $type,
    ‘post_status’ => ‘publish’,
    ‘paged’ => $paged,
    ‘posts_per_page’ => 9,
    ‘caller_get_posts’=> 1
    );
    $temp = $wp_query; // assign original query to temp variable for later use
    $wp_query = null;
    $wp_query = new WP_Query();
    $wp_query->query($args);
    ?>
    <?php if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); ?>
    <div id=”portfolio-item”>
    <h1><?php the_title(); ?></h1>
    “><?php the_post_thumbnail(); ?>
    <?php the_content(); ?>
    </div>
    <?php endwhile; else : ?>
    <?php endif; ?>
    </div>

    <div align=”right”>
    <?php if(function_exists(‘wp_pagenavi’)) { wp_pagenavi(); }
    $wp_query = null; $wp_query = $temp; ?>
    </div>
    <?php get_footer(); ?>

    and here is the code for function:

    <?php
    // Create Portfolio
    add_action(‘init’, ‘create_portfolio’);
    function create_portfolio() {
    $portfolio_args = array(
    ‘label’ => __(‘Portfolio’),
    ‘singular_label’ => __(‘Portfolio’),
    ‘public’ => true,
    ‘show_ui’ => true,
    ‘capability_type’ => ‘post’,
    ‘hierarchical’ => false,
    ‘rewrite’ => true,
    ‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’)
    );
    register_post_type(‘portfolio’,$portfolio_args);
    }
    ?>
    <?php
    add_action(“admin_init”, “add_portfolio”);
    add_action(‘save_post’, ‘update_website_url’);
    function add_portfolio(){
    add_meta_box(“portfolio_details”, “Portfolio Options”, “portfolio_options”, “portfolio”, “normal”, “low”);
    }
    function portfolio_options(){
    global $post;
    $custom = get_post_custom($post->ID);
    $website_url = $custom[“website_url”][0];
    ?>
    <div id=”portfolio-options”>
    <label>Website URL:</label><input name=”website_url” value=”<?php echo $website_url; ?>” />
    </div><!–end portfolio-options–>
    <?php
    }
    function update_website_url(){
    global $post;
    update_post_meta($post->ID, “website_url”, $_POST[“website_url”]);
    }
    ?>
    <?php
    add_filter(“manage_edit-portfolio_columns”, “portfolio_edit_columns”);
    add_action(“manage_posts_custom_column”, “portfolio_columns_display”);

    function portfolio_edit_columns($portfolio_columns){
    $portfolio_columns = array(
    “cb” => “<input type=\”checkbox\” />”,
    “title” => “Project Title”,
    “description” => “Description”,
    );
    return $portfolio_columns;
    }

    function portfolio_columns_display($portfolio_columns){
    switch ($portfolio_columns)
    {
    case “description”:
    the_excerpt();
    break;
    }
    }
    ?>

    There are too much longer… :D..

    Please help me out of this problem!

    Hi, if I understand your question correctly I think you may need some custom taxonomies to go with your custom post type. If that sounds good check this page out;

    http://codex.wordpress.org/Function_Reference/register_taxonomy

    Dan

    <h1><?php the_title(); ?></h1>
    "><?php the_post_thumbnail(); ?>
    <?php the_content(); ?>

    That “> in your code above is also wrong ; )

    Thread Starter LSP Sopheak

    (@lsp_sopgheak)

    Thanks g3legacy!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to create categories in Portfolio?’ is closed to new replies.