Post Thumbnails

//add this to the functions.php file
add_theme_support( 'post-thumbnails' );

//add this to the functions.php file this to only add to page templates not posts
add_theme_support( 'post-thumbnails', array( 'page' ) );

//Show the thumbnail
<?php the_post_thumbnail( 'thumbnail' ); ?>

//Show the thumbnail as medium
<?php the_post_thumbnail( 'medium' ); ?>

//Change thumbnail size

if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'game-thumb', 100, 74 ,true);//true arg is for hard crop
}

//Use a conditional

<?php if ( has_post_thumbnail() ) the_post_thumbnail('game-thumb'); ?>

//Change the title attribute

<?php the_post_thumbnail( 'post-thumbnail', array( 'title' => $title, 'alt' => $title ) ); ?>

Parent Cat ID for single.php

<?php

foreach((get_the_category()) as $childcat) {

$parentcat = $childcat->category_parent;

$the_cat_name = get_cat_name($parentcat);

$the_cat_ID = get_cat_ID($the_cat_name);

}
if($the_cat_ID == 4){
echo "parent cat $the_cat_ID <br />";
}
?>

Category and Post ID worksheet

<?php
 // This function retreives category ID from an archive page
 function getCurrentCatID(){ 
  global $wp_query; 
  if(is_category() || is_single()){ 
   $cat_ID = get_query_var('cat');
  } 
   return $cat_ID; 
 } 
 echo 'Function Category ID = ';
 echo getCurrentCatID();
 
 echo 'Function Category ID = ' . get_query_var('cat');
 ?>
    
    <br />
 
 
 <?php
 //This retreives category ID from an archive page
 echo 'Cat = ' . get_query_var('cat');
 ?>
  
 <br />
  
  
   <?php
   //The Category ID - In and Out (Use False to prevent echo) *only works for child category
   echo 'Category ID = ';
   the_category_ID( );
   ?>

      <br />
     
      <?php echo 'Category Name = ' . get_cat_name(the_category_ID(false)); ?>
     
      <br />

      <?php
   if (cat_is_ancestor_of( 53 , the_category_ID(false))){
  echo 'In Category 53? = Yes';
   } else echo 'In Category 53? = No';
   ?>
     
      <br />
     
      <?php //$post-> ID - In and Out
   echo 'Post ID = ' . $post->ID;
   ?>
     
      <br />
     
      <p>Begin WordPress Loop</p>
     
     
     
      <!-- ~~~~~~~~~~~~~~ The Loop ~~~~~~~~~~~~~~~ -->
     
      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
     
   
     
      <?php //Get The ID - Loop Only
   echo 'Post ID = ' . get_the_ID();
   ?>
  
   <br />
  
   <?php //The ID - Loop Only (Use False to prevent echo)
   echo 'Post ID = ';
   the_ID();
   ?>
  
   <?php endwhile; endif; ?>