Title: Different Post Types with Custom Fields
Last modified: August 19, 2016

---

# Different Post Types with Custom Fields

 *  [casanovaruffin](https://wordpress.org/support/users/casanovaruffin/)
 * (@casanovaruffin)
 * [15 years, 12 months ago](https://wordpress.org/support/topic/different-post-types-with-custom-fields/)
 * Hello,
 * Does anyone have any idea how to do different post types with custom fields? 
   I have a n00b’s understanding of PHP, but I still think it’s worth trying.
 * I found this tutorial on how to choose between php the_excerpt and php the_content
   for different posts, but I don’t know how to fit into my theme. Here’s the site
   I’m messing around with… [http://omega.steelcloset.com/](http://omega.steelcloset.com/)
 * Here’s the tutorial:
 * [http://www.wprecipes.com/how-to-manually-define-to-show-full-post-or-excerpt-on-your-homepage](http://www.wprecipes.com/how-to-manually-define-to-show-full-post-or-excerpt-on-your-homepage)
 * Here’s the code for the custom field trick…
 * <?php if (have_posts()) :
    while (have_posts()) : the_post(); $customField = 
   get_post_custom_values(“full”); if (isset($customField[0])) { //Custom field 
   is set, display a full post the_title(); the_content(); } else { // No custom
   field set, let’s display an excerpt the_title(); the_excerpt(); endwhile; endif;?
   >
 * And here’s my index.php… I know where the post section is in the index. I’m just
   including all of it for reference.
 * > <?php get_header(); ?>
   >  <?php if(!is_paged()) { ?>
   >  <div id=”top” class=”clearfloat”>
   >  <div id=”headline”>
   >  <img src=”[http://omega.steelcloset.com/wp-content/themes/arthemia/arthemia/images/headline.png&#8221](http://omega.steelcloset.com/wp-content/themes/arthemia/arthemia/images/headline.png&#8221);
   > width=”75px” height=”21px” alt=”” /> <?php query_posts(“showposts=1&category_name
   > =Headline”); ?> <?php while (have_posts()) : the_post(); ?>
   > </div>
   >  <div class=”meta”>[<?php the_time(‘j M Y’) ?> | <?php comments_popup_link(‘
   > No Comment’, ‘One Comment’, ‘% Comments’);?> | <?php if(function_exists(‘the_views’)){
   > the_views(); } ?>]</div> <?php $values = get_post_custom_values(“Headline”);?
   > > ” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”> <img src
   > =”<?php echo bloginfo(‘template_url’); ?>/scripts/timthumb.php?src=/<?php $
   > values = get_post_custom_values(“Image”); echo $values[0]; ?>&w=300&h=275&zc
   > =1&q=100″ alt=”<?php the_title(); ?>” class=”left” width=”300px” height=”275px”/
   > > <?php the_excerpt(); ?> ” rel=”bookmark” title=”Permanent Link to <?php the_title();?
   > >”>Read the full story » <?php endwhile; ?> </div>
   >  <div id=”featured”>
   >  <img src=”[http://omega.steelcloset.com/wp-content/themes/arthemia/arthemia/images/featured.png&#8221](http://omega.steelcloset.com/wp-content/themes/arthemia/arthemia/images/featured.png&#8221);
   > width=”72px” height=”17px” alt=”” />
   >  <?php query_posts(“showposts=4&category_name=Featured”); $i = 1; ?>
   >  <?php while (have_posts()) : the_post(); ?>
   >  <div class=”clearfloat”> <?php
   > $values = get_post_custom_values(“Image”); if (isset($values[0])) { ?> ” rel
   > =”bookmark” title=”Permanent Link to <?php the_title(); ?>”> <img src=”<?php
   > echo bloginfo(‘template_url’); ?>/scripts/timthumb.php?src=/<?php $values =
   > get_post_custom_values(“Image”); echo $values[0]; ?>&w=100&h=65&zc=1&q=100″
   > alt=”<?php the_title(); ?>” class=”left” width=”100px” height=”65px” /> <?php}?
   > > <div class=”info”>” rel=”bookmark” class=”title”><?php the_title(); ?> <div
   > class=”meta”>[<?php the_time(‘j M Y’) ?> | <?php comments_popup_link(‘No Comment’,‘
   > One Comment’, ‘% Comments’);?> | <?php if(function_exists(‘the_views’)) { the_views();}?
   > >]</div> <?php the_category(‘, ‘); ?> <p></p> <div class=”text”> <?php $key
   > = ‘Text’; $Text = get_post_meta($post->ID, $key, TRUE); if($Text != ”) { echo
   > $Text; } ?> </div>
   > </div>
   >  </div>
   >  <?php endwhile; ?>
   >  </div>
   > </div>
   >  <div id=”middle” class=”clearfloat”>
   >  <img src=”[http://omega.steelcloset.com/wp-content/themes/arthemia/arthemia/images/category.png&#8221](http://omega.steelcloset.com/wp-content/themes/arthemia/arthemia/images/category.png&#8221);
   > class=”clearfloat” alt=”” /> <?php $display_categories = array(5,6,7,8,11);
   > $i = 1; foreach ($display_categories as $category) { ?>
   >  <div id=”cat-<?php echo $i; ?>” class=”category”>
   >  <?php query_posts(“showposts
   > =1&cat=$category”)?> <span class=”cat_title”>“><?php single_cat_title(); ?>
   > </span> “><?php echo category_description($category); ?> </div>
   >  <?php $i++; ?>
   >  <?php } ?>
   >  </div>
   >  <?php } ?>
   >  <div id=”bottom” class=”clearfloat”>
   >  <div id=”front-list”>
   >  <?php
   >  $page = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts(“
   > cat=-27,-28&paged=$page&posts_per_page=5”); ?>
   >  <?php while (have_posts()) : the_post(); ?>
   >  <div class=”clearfloat”>
   > <h3 class=cat_title><?php the_category(‘, ‘); ?> &raquo</h3>
   >  <div class=”text”
   > > <?php $key = ‘Text’; $Text = get_post_meta($post->ID, $key, TRUE); if($Text!
   > = ”) { echo $Text; } ?> </div><div class=”title”>” rel=”bookmark”><?php the_title();?
   > ></div> <div class=”meta”>[<?php the_time(‘j M Y’) ?> | <?php comments_popup_link(‘
   > No Comment’, ‘One Comment’, ‘% Comments’);?> | <?php if(function_exists(‘the_views’)){
   > the_views(); } ?>]</div>
   >  <div class=”spoiler”>
   >  <?php $values = get_post_custom_values(“Image”);
   >  if (isset($values[0])) {?
   > > ” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”> <img src
   > =”<?php echo bloginfo(‘template_url’); ?>/scripts/timthumb.php?src=/<?php $
   > values = get_post_custom_values(“Image”); echo $values[0]; ?>&w=200&h=200&zc
   > =1&q=100″ alt=”<?php the_title(); ?>” class=”left” width=”200px” height=”200px”/
   > > <?php } ?>
   > 
   >  </div>
   >  </div>
   >  <?php endwhile; ?>
   >  <div class=”navigation”>
   >  <?php if(function_exists(‘wp_pagenavi’)) { wp_pagenavi();}
   > else { ?>
   >  <div class=”right”><?php next_posts_link(‘Next Page »’) ?></div>
   >  <div class
   > =”left”><?php previous_posts_link(‘« Previous Page’) ?></div> <?php } ?>
   >  </div>
   >  </div>
   >  <?php get_sidebar(); ?>
   >  </div>
   > <?php get_footer(); ?>

Viewing 1 replies (of 1 total)

 *  Thread Starter [casanovaruffin](https://wordpress.org/support/users/casanovaruffin/)
 * (@casanovaruffin)
 * [15 years, 12 months ago](https://wordpress.org/support/topic/different-post-types-with-custom-fields/#post-1505320)
 * Here’s what I got so far…
 * I typed this in the index:
 * <?php
    $key = ‘full’; $full = get_post_meta($post->ID, $key, TRUE); if($full !
   = ”) { echo the_content(); } else { the_excerpt(); } ?>
 * When I type something in the “full” custom field, it switches to php the_content.
   When I don’t use the “full” custom field, it goes to php_the excerpt as a default.
 * This is all good and well, but I can’t get the post thumbnail to show up for 
   the excerpt.
 * This is how it looks normally for php the_excerpt with a working thumbnail:
 * <?php $values = get_post_custom_values(“Image”);
    if (isset($values[0])) { ?>”
   rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”> <img src=”<?php
   echo bloginfo(‘template_url’); ?>/scripts/timthumb.php?src=/<?php $values = get_post_custom_values(“
   Image”); echo $values[0]; ?>&w=200&h=200&zc=1&q=100″ alt=”<?php the_title(); ?
   >” class=”left” width=”200px” height=”200px” /> <?php } ?>
 * 
 * When I try to put this in the if else statement, it doesn’t work.
 * Any ideas?

Viewing 1 replies (of 1 total)

The topic ‘Different Post Types with Custom Fields’ is closed to new replies.

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [Post Types](https://wordpress.org/support/topic-tag/post-types/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [casanovaruffin](https://wordpress.org/support/users/casanovaruffin/)
 * Last activity: [15 years, 12 months ago](https://wordpress.org/support/topic/different-post-types-with-custom-fields/#post-1505320)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
