Guest User

get custom fields

a guest
Apr 21st, 2012
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.37 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: Custom Fields Testing Page
  4. */
  5. ?>
  6. <?php get_header(); ?>
  7.  
  8.             <!-- Below are the functions to get the custom fields -->
  9.        
  10.         <?php $featuredpost_cat = get_field('featured_category_id'); ?>
  11.        
  12.             <!-- THINGS TO CHANGE category IDs to the category you want to show on lines 25 and 74.  Remember to change the custom menu function name on line 20. AND remember to change more posts link at bottom.  Also set custom sidebar in get_sidebar call at bottom -->
  13.             <!-- BEGIN MAIN -->
  14.             <!-- BEGIN MAIN -->
  15.             <div id="main">
  16.                
  17.                 <div class="post-heading page">
  18.                    
  19.                     <h1><?php the_title(); ?></h1>
  20.                
  21.                 </div><!-- end div class post-heading page -->
  22.                
  23.                 <div id="sub_homepages_page_secondary_nav">
  24.                         <?php wp_nav_menu(array('theme_location' => 'community_page_menu')); ?> <a href="#morenav" style="color:white;">more...</a>
  25.                     </div><!-- end div id sub_homepages_page_secondary_nav -->
  26.                    
  27.                 <!-- query the category and leave showing one post -->
  28.                 <div id="top_of_community_page">
  29.                     <?php query_posts('?cat='.$featuredpost_cat . '&posts_per_page=1'); if (have_posts()) : while (have_posts()) : the_post(); ?>
  30.  
  31.                     <div id="post-<?php the_ID(); ?>" <?php post_class('cat-homepage-big'); ?>>
  32.                         <?php
  33.                         if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
  34.                             $icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
  35.                         } else {
  36.                             $icon = '';
  37.                         }
  38.                         ?>
  39.                         <!-- gets the featured image from this post -->
  40.                             <div id="featured_image_background_holder">
  41.                                 <?php if(has_post_thumbnail()): ?>
  42.                                 <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'featured-image'); ?>
  43.                                 <div class="block-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>"  width='516' height='340' /></a><?php echo $icon; ?></div>
  44.                                 <?php endif; ?>
  45.                                 <h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?></a></h2>
  46.                                 <span class="block-meta">
  47.                                     <span class="heading-author"><?php the_author(); ?></span>
  48.                                     <span class="heading-date"><?php the_time('F j, Y'); ?></span>
  49.                                     <span class="heading-comments"><?php comments_popup_link('0','1','%'); ?></span>
  50.                                 </span>
  51.                                 <p><?php echo string_limit_words(get_the_excerpt(), 34); ?></p><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>' class="readmore"><?php _e('Read More', 'Avenue'); ?> <span class="block-arrows">&raquo;</span></a>
  52.                             </div><!-- end div id featured_image_background_holder -->
  53.                     </div>
  54.                     <?php endwhile; endif; ?>
  55.                    
  56.                 <a name="morenav"></a>
  57.                    
  58.                 </div><!-- end div id top_of_community_page -->
  59.                
  60.                 <div id="community_menu_blocks">
  61.                 <h1 style="font-size:30px;text-align:center;">What Are You Looking For?</h1>
  62.                     <div id="left_comm_block">
  63.                         <?php if (!dynamic_sidebar('community_page_sidebar_lower_left')) : ?>
  64.                         <?php endif; ?>
  65.                     </div><!-- end div id left_comm_block -->
  66.                        
  67.                     <div id="right_comm_block">
  68.                         <?php if (!dynamic_sidebar('community_page_sidebar_lower_right')) : ?>
  69.                         <?php endif; ?>
  70.                     </div><!-- end div id right_comm_block -->
  71.                
  72.                 </div><!-- end div id community_menu_blocks -->
  73.                
  74.             <div id="category_homepage">   
  75.                
  76.                 <div class="block archive">
  77.            
  78.                
  79.                 <?php query_posts('cat=23&posts_per_page=3&offset=1'); if (have_posts()) : while (have_posts()) : the_post(); ?>
  80.                     <div id="post-<?php the_ID(); ?>" <?php post_class('block-item-big'); ?>>
  81.                         <?php
  82.                         if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
  83.                             $icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
  84.                         } else {
  85.                             $icon = '';
  86.                         }
  87.                         ?>
  88.                        
  89.                         <?php if(has_post_thumbnail()): ?>
  90.                         <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image'); ?>
  91.                         <div class="block-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>"  width='290' height='160' /></a><?php echo $icon; ?></div>
  92.                         <?php endif; ?>
  93.                         <h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?></a></h2>
  94.                         <span class="block-meta">
  95.                             <span class="heading-author"><?php the_author(); ?></span>
  96.                             <span class="heading-date"><?php the_time('F j, Y'); ?></span>
  97.                             <span class="heading-comments"><?php comments_popup_link('0','1','%'); ?></span>
  98.                         </span>
  99.                         <p><?php echo string_limit_words(get_the_excerpt(), 34); ?></p><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>' class="readmore"><?php _e('Read More', 'Avenue'); ?> <span class="block-arrows">&raquo;</span></a>
  100.                     </div>
  101.                     <?php endwhile; endif; ?>
  102.                    
  103.                     <h4 style="font-size:24px;float:right;"><a href="http://geauganews.com/geauga-county-ohio/community-news/" style="color:green;">Read all our Community Post Archives &#8594;</a></h4>
  104.                    
  105.                 </div><!-- end div class block archive -->
  106.                
  107.             </div><!-- end div id category_homepage -->
  108.                
  109.             </div><!-- END MAIN -->
  110.                 <br />         
  111. <!-- change sidebar below to reflect pages sidebar -->             
  112.                
  113. <?php get_sidebar('community'); ?>
  114.            
  115. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment