Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Dharmesh Sheth
Dharmesh Sheth
2,547 Points

Adding tags or category on custom post type portfolio?

hi there how do I add the category or tags? example logo, business cards etc

<?php
   add_action('init', 'portfolio_register');  

function portfolio_register() {  
    $args = array(  
        'label' => __('Portfolio'),  
        'singular_label' => __('Project'),  
        'public' => true,  
        'show_ui' => true,  
        'capability_type' => 'post',  
        'hierarchical' => false,  
        'rewrite' => true,  
        'supports' => array('title', 'editor', 'thumbnail', 'categories' )  
       );  flush_rewrite_rules(); 

    register_post_type( 'portfolio' , $args ); 



  $args = array(
    'post_type' => 'portfolio',
    'posts_per_page' => $num_posts
  );
  $query = new WP_Query( $args );

?>

     <?php if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); ?>         





                        <article>
                            <div class="image fit">



                                <?php the_post_thumbnail(); ?>
                            </div>
                            <header>
                                <h3><?php the_title(); ?></h3>
                                    <p><?php the_tags ( ', ' ); ?>.</p> 
                            </header>

                            <footer>
                                <a href="<?php the_permalink(); ?>" class="btn btn-success">More</a>
                            </footer>
                        </article>





                 <?php endwhile; endif; wp_reset_postdata(); ?>