Title: Custom Post Type help
Last modified: August 30, 2016

---

# Custom Post Type help

 *  Resolved [teamcanada613](https://wordpress.org/support/users/teamcanada613/)
 * (@teamcanada613)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-help-3/)
 * hey, so I’m a little confused, I’ve been searching for hours, I’ve made a custom
   post type for a portfolio section, and I have posts within it called projects,
   I want to pull the post title/featured image and category its under from the 
   featured category, so the posts will have 2 categories, the featured being the
   option that displays them on a certain page, and another for a certain part of
   my design
 * its an image (which i want to pull the featured from)
    with a mouse overlay that
   will show the Project title, and the category
 * so like
 * Web Company – title
    Development – category (also in the featured but don’t want
   featured being displayed
 * i’ve found this code on the site, and was wondering how i could do it, the slug
   is project so example
 * localhost/project/web-company
    also i want either 3 of these to loop or 6 if 
   possible.
 *     ```
       <?php
       query_posts('cat=7&posts_per_page=3');
       if(have_posts()) :
         while(have_posts()) :
           the_post();
           ?>
           <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
             <h2><?php permalink(); ?></h2>
             <div class="entry">
             <?php
             $img = get_post_meta($post->ID, 'Featured Thumbnail', true);
             ?><img src="<?php echo $img; ?>"/><?php
             the_content('Read More');
             ?>
             </div>
           </div>
           <?php
         endwhile;
       endif;
       wp_reset_query();
       ?>
       ```
   

Viewing 11 replies - 1 through 11 (of 11 total)

 *  [Artur Bobinski](https://wordpress.org/support/users/kentonwebdesign/)
 * (@kentonwebdesign)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-help-3/#post-6888751)
 * Hi, I would probably start with something g like this;
 *     ```
       <?php
       $type = 'projects';
       $args=array(
         'post_type' => $type,
         'post_status' => 'publish',
         'posts_per_page' => -1,
         'caller_get_posts'=> 1
   
       $my_query = null;
       $my_query = new WP_Query($args);
   
       if( $my_query->have_posts() ) {
         while ($my_query->have_posts()) : $my_query->the_post(); ?>
   
           <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
             <h2><?php permalink(); ?></h2>
             <div class="entry">
             <?php
             $img = get_post_meta($post->ID, 'Featured Thumbnail', true);
             ?><img src="<?php echo $img; ?>"/><?php
             the_content('Read More');
             ?>
             </div>
           </div>
           <?php
         endwhile;
       wp_reset_query();
       ?>
       ```
   
 *  [Artur Bobinski](https://wordpress.org/support/users/kentonwebdesign/)
 * (@kentonwebdesign)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-help-3/#post-6888752)
 * Oops forgot you wanted only 3 or 6 to display;
 *     ```
       <?php
       $type = 'projects';
       $args=array(
       'post_type' => $type,
       'post_status' => 'publish',
       'posts_per_page' => 3
   
       $my_query = null;
       $my_query = new WP_Query($args);
   
       if( $my_query->have_posts() ) {
       while ($my_query->have_posts()) : $my_query->the_post(); ?>
   
       <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
       <h2><?php permalink(); ?></h2>
       <div class="entry">
       <?php
       $img = get_post_meta($post->ID, 'Featured Thumbnail', true);
       ?><img src="<?php echo $img; ?>"/><?php
       the_content('Read More');
       ?>
       </div>
       </div>
       <?php
       endwhile;
       wp_reset_query();
       ?>
       ```
   
 *  Thread Starter [teamcanada613](https://wordpress.org/support/users/teamcanada613/)
 * (@teamcanada613)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-help-3/#post-6888768)
 * thank you for your help,
 * i broke it down to this
 *     ```
       <?php
           $args = array(
               'post_type' => 'project',
               'post_status' => 'publish',
               'posts_per_page' => 3 );
   
           $loop = new WP_Query( $args );
   
           while ( $loop->have_posts() ) : $loop->the_post();
               the_title();
               the_category();
   
           endwhile;
   
       ?>
       ```
   
 * i dont want the category to be a link, and also i want to know how to make a 
   link out of each post
 *  [Artur Bobinski](https://wordpress.org/support/users/kentonwebdesign/)
 * (@kentonwebdesign)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-help-3/#post-6888769)
 * Hi,
 * Wouldn’t this work?
 *     ```
       <?php
           $args = array(
               'post_type' => 'project',
               'post_status' => 'publish',
               'posts_per_page' => 3 );
   
           $loop = new WP_Query( $args );
   
           while ( $loop->have_posts() ) : $loop->the_post();
               the_title();
               the_category(', ');
   
           endwhile;
   
       ?>
       ```
   
 * Thank you.
 *  Thread Starter [teamcanada613](https://wordpress.org/support/users/teamcanada613/)
 * (@teamcanada613)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-help-3/#post-6888770)
 * no, thank you!
 * the change in the
 * `the_category();`
 * was perfect.
 * Just wondering, do you know the function to obtain the link of each post to add
   into the loop?
 * cant figure it out still searching for it, i found the featured image part i 
   was looking for =)
 *  [Artur Bobinski](https://wordpress.org/support/users/kentonwebdesign/)
 * (@kentonwebdesign)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-help-3/#post-6888773)
 * Hi,
 * Normally you’d use permalink … So the_permalink();
 * Hope that helps.
 * Thank you.
 *  Thread Starter [teamcanada613](https://wordpress.org/support/users/teamcanada613/)
 * (@teamcanada613)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-help-3/#post-6888774)
 * that was it, i was trying it with the_ so now it works also
 * the_category(‘, ‘);
 * still is a link, do u know to how to stop that?
 *  Thread Starter [teamcanada613](https://wordpress.org/support/users/teamcanada613/)
 * (@teamcanada613)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-help-3/#post-6888777)
 * the solution for category was this
 *     ```
       $categories = get_the_category();
   
       if ( ! empty( $categories ) ) {
           echo esc_html( $categories[0]->name );
       }
       ```
   
 *  [Artur Bobinski](https://wordpress.org/support/users/kentonwebdesign/)
 * (@kentonwebdesign)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-help-3/#post-6888778)
 * Hi,
 * Was gonna post that just as I refreshed 🙂 glad you got that part working
 *  Thread Starter [teamcanada613](https://wordpress.org/support/users/teamcanada613/)
 * (@teamcanada613)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-help-3/#post-6888779)
 * thanks a ton for your help and your time =)
 *  [Artur Bobinski](https://wordpress.org/support/users/kentonwebdesign/)
 * (@kentonwebdesign)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-help-3/#post-6888780)
 * Hi,
 * Was gonna post that just as I refreshed 🙂 glad you got that part working

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Custom Post Type help’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 11 replies
 * 2 participants
 * Last reply from: [Artur Bobinski](https://wordpress.org/support/users/kentonwebdesign/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-help-3/#post-6888780)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
