Guest User

Custom fields

a guest
Dec 22nd, 2011
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.39 KB | None | 0 0
  1. <h2>Resources</h2>
  2. <?php
  3.     $item = get_post_meta($post->ID, 'Resources', true);
  4.        
  5.         if($item !=='')
  6.             { ?>
  7.             <div class="cb-cf"><?php echo $item ?></div>
  8.             <?php
  9.             }
  10.            
  11.             else { ?>
  12.             <ul>
  13.                 <?php $wp = new WP_Query('category_name=white-papers&posts_per_page=1'); if($wp->have_posts()) : while($wp->have_posts()) : $wp->the_post(); ?>
  14.                     <li><a href="<?php the_permalink(); ?>">White Paper: <?php the_title(); ?></a></li>
  15.                 <?php endwhile; endif; ?>
  16.    
  17.                 <?php $cs = new WP_Query('category_name=case-studies&posts_per_page=1'); if($cs->have_posts()) : while($cs->have_posts()) : $cs->the_post(); ?>
  18.                     <li><a href="<?php the_permalink(); ?>">Case Study: <?php the_title(); ?></a></li>
  19.                 <?php endwhile; endif; ?>
  20.             </ul>
  21.             <?php   }  ?>
  22.        
  23.  
  24.  
  25. <h2>News</h2>
  26. <?php $item2 = get_post_meta($post->ID, 'News', true);
  27.        
  28.         if($item2 !=='')
  29.             { ?>
  30.                 <div class="cb-cf"><?php echo $item2 ?></div>
  31.             <?php
  32.             }
  33.            
  34.             else { ?>
  35.             <ul>
  36.              <?php $news = new WP_Query('category_name=news&posts_per_page=3'); if($news->have_posts()) : while($news->have_posts()) : $news->the_post(); ?>
  37.                     <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
  38.              <?php endwhile; endif; ?>
  39.              </ul>
  40.         <?php   }  ?>
Advertisement
Add Comment
Please, Sign In to add comment