• We are a high school trying to relaunch our online news site. We have everything working on our new site, except our custom fields. Would anyone be able to look at the code and tell us if we have something wrong here? The photos, videos, galleries etc. are not pulling into the posts.

    http://www.southwestshadow.com

    <?php include(TEMPLATEPATH."/breadcrumb.php");?>
    <?php  $mediacount=0; if (have_posts()) : while (have_posts()) : the_post(); ?>
                <h1><a>" rel="bookmark"><?php the_title(); ?></a></h1>
    
                <?php global $post; $photographer = get_post_meta($post->ID, photographer, true); $teasertitle = get_post_meta($post->ID, teasertitle, true); $teaser = get_post_meta($post->ID, teaser, true); $grade = get_post_meta($post->ID, grade, true); $reviewthumbnail = get_post_meta($post->ID, reviewthumbnail, true); $showratings = get_post_meta($post->ID, showratings, true); $audio = get_post_meta($post->ID, audio, true); $caption = get_post_meta($post->ID, caption, true); $video = get_post_meta($post->ID, video, true); $trailer = get_post_meta($post->ID, trailer, true); $soundslides = get_post_meta($post->ID, soundslides, true); $soundslidescredit = get_post_meta($post->ID, soundslidescredit, true); $slideshow = get_post_meta($post->ID, slideshow, true); $slideshowcredit = get_post_meta($post->ID, slideshowcredit, true); $videographer = get_post_meta($post->ID, videographer, true);?>
    <?php $slideshowwidth = get_theme_mod('mm-width'); $slideshowheight = get_theme_mod('mm-height'); $sswidth = (int)$slideshowwidth; $ssheight = (int)$slideshowheight;  $sswidthgallery = $sswidth; $ssheightgallery = $ssheight - 50;  $videowidth = get_theme_mod('mm-width'); $videoheight = get_theme_mod('mm-height'); $videoheight -= 50; ?>
                           <?php if ($teasertitle) { ?>
                              <div id="teaserbox" style="float:right">
    
    <?php global $post; $feature_photo = get_post_meta($post->ID, review_thumbnail, true); if (has_post_thumbnail())
    			{ the_post_thumbnail( 'ae', array('class' => 'reviewthumbnail')); }
    	else if ($feature_photo) { ?><a>"><img src="<?php echo $feature_photo; ?>" class="reviewthumbnail" style="width:60px" /></a><?php }
    	else
    			{ global $wpdb; $attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1");
    $attachment = wp_get_attachment_url($attachment_id); if ($attachment) { ?><a>"><img src="<?php echo $attachment; ?>" class="reviewthumbnail" style="width:60px" /></a><?php } } ?>
    
                                 <?php if ($teasertitle) { ?><a>" class="teasertitle"><?php echo $teasertitle; ?></a><?php } else { the_title(); } ?>
                                 <p class="teasertext"><?php echo $teaser; ?></p>
                                 <?php if ($grade) { ?><p class="teasergrade">Our Rating: <?php echo $grade; ?></p><?php } ?>
                                 <?php if ($audio) { ?><div style="clear:both;margin-bottom:15px;"></div><?php $audioplayer = "[audio:" . $audio . "]"; if (function_exists('insert_audio_player')) { insert_audio_player($audioplayer); } } ?>
                               </div>
                           <?php } else { ?>
    <?php global $post; $feature_photo = get_post_meta($post->ID, feature_photo, true); if (has_post_thumbnail())
    			{ the_post_thumbnail( 'archive', array('class' => 'categoryimage')); }
    	else if ($feature_photo) { ?><a>"><img src="<?php echo $feature_photo; ?>" class="categoryimage" style="width:200px" /></a><?php }
    	else
    			{ global $wpdb; $attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1");
    $attachment = wp_get_attachment_url($attachment_id); if ($attachment) { ?><a>"><img src="<?php echo $attachment; ?>" class="categoryimage" style="width:200px" /></a><?php } } ?>
    
                    <?php if ($audio) { ?><div style="width:300px;"><?php $audioplayer = "[audio:" . $audio . "]"; if (function_exists('insert_audio_player')) { insert_audio_player($audioplayer); } echo '</div>'; } ?>
    
                           <?php } ?>
    
                <p><?php snowriter(); the_time('F j, Y'); edit_post_link('(Edit)', ' • ', ''); ?></p>
    
                <?php the_content_limit(300, "Read more »"); ?><div style="clear:both;"></div>
    
    <?php $mmcheck = get_option('msno'); if ($mmcheck == "msno402841m") { ?>
    
              <?php if ($slideshow) { $mediacount++; ?>
    
                    <div class="videoplay2"><a>&height=<?php echo $ssheight; ?>&width=<?php echo $sswidth; ?>" title="<?php the_title();?>" class="thickbox" style="font-size:22px;line-height:30px;">Watch Slideshow</a></div><div style="clear:both"></div>
                           <div id = "media<?php echo $mediacount; ?>" style = "display: none;">
                         <?php if ($slideshow) { $showalbum = "[slideshow id =" . $slideshow . " w=" . $sswidthgallery . " h=" . $ssheightgallery ."]"; echo do_shortcode($showalbum); ?><div style="margin-bottom:15px"></div><?php } ?>
                         <?php $slideshowcredit = get_post_meta($post->ID, slideshowcredit, true); if ($slideshowcredit) { ?><div class="mmdivider"><p class="photographer">Slideshow Credit: <?php echo $slideshowcredit; ?></p></div><?php } ?>
                           </div>
              <?php } ?>
    
              <?php if ($soundslides) { ?>
                          <?php $mediacount++; ?>
                    <div class="videoplay2"><a>&height=<?php echo $ssheight; ?>&width=<?php echo $sswidth; ?>" title="<?php the_title();?>" class="thickbox" style="font-size:22px;line-height:30px;">Watch Slideshow</a></div><div style="clear:both"></div>
                           <div id = "media<?php echo $mediacount; ?>" style = "display: none;">
                               <?php if ($soundslides) { $pattern = "/height=\"[0-9]*\"/"; $soundslides = preg_replace($pattern, "height=' " . $videoheight . " '", $soundslides); $pattern = "/width=\"[0-9]*\"/"; $soundslides = preg_replace($pattern, "width=' " . $videowidth . " '", $soundslides); echo $soundslides; } ?>
                               <?php $soundslidecredit = get_post_meta($post->ID, soundslidescredit, true); if ($soundslidescredit) { ?><div class="mmdivider"><p class="photographer">Slideshow Credit: <?php echo $soundslidescredit; ?></p></div><?php } ?>
                           </div>
             <?php } ?>
    
    <?php } ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi mrlaporte,

    I’m noticing php fatal errors in all your get_post_meta calls.

    get_post_meta($post->ID, photographer, true);

    The 2nd parameter meta_key is a string and needs to be between quotation marks.

    get_post_meta( $post->ID, 'photographer', true );

    Is the correct way to call the custom field.

    Thread Starter mrlaporte

    (@mrlaporte)

    I’m going to try this out!

    I will post if it works!

    Thread Starter mrlaporte

    (@mrlaporte)

    Chris,

    This did not make a change. Let me know if I did this right.

    <?php get_header(); ?>
    <?php $template = get_post_meta( $post->ID, 'wpzoom_post_template', true); ?>
    <div id="content-wrap">
    <div class="container">
    	<div class="row">
    		<div class="eightcol">
    
    <div id="content" class="single<?php if ($template == 'full') {echo " full-width";} ?>">
    
    	<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
    
    			if ( option::get('post_category') == 'on' ) {
    				?><h3 class="topcat"><?php the_category(''); ?></h3><div class="clear"></div><?php
    			} ?>
    
    			<div class="post" id="single">
    
    				<h1><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
    
    				<ul class="post-meta">
    					<?php
    					if ( option::get('post_date') == 'on' ) { ?><li class="date"><?php printf( __('%s at %s', 'wpzoom'),  get_the_date(), get_the_time()); ?><?php }
    					if ( option::get('post_author') == 'on' ) { ?><li class="author"><?php the_author_posts_link(); ?><?php }
    					if ( option::get('display_comm_count') == 'on' ) { ?><li class="comments"><?php comments_popup_link( __('0 comments', 'wpzoom'), __('1 comment', 'wpzoom'), __('% comments', 'wpzoom') ); ?><?php }
    					edit_post_link( __('EDIT', 'wpzoom'), '<li class="edit">', '' );
    					?>
    
    				<div class="entry">
    
    				<div id="bigpic">
    
    <?php the_post_thumbnail();
    echo get_post(get_post_thumbnail_id())->post_content; ?>
    
    								<?php global $wpdb; $attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1"); ?>
    								<?php if ($attachment_id) $cpphotographer = get_post_meta( $attachment_id, 'photographer', true); ?>
                                  	<?php if (($cpphotographer) || ($photographer)) { ?><p class="photocredit">Photo Credit: <?php if ($cpphotographer) { echo $cpphotographer; } else { echo $photographer; } ?></p><?php } ?>
    
    								<?php if ($attachment_id) $cpphoto = get_post($attachment_id); $cpcaption = $cpphoto->post_content; ?>
     	                            <?php if (($cpcaption) || ($caption)) { ?><p class="photocaption"><?php if ($cpcaption) {echo $cpcaption; } else { echo $caption; } ?></p><?php } ?>
    
    </div>
    
    				<?php the_content(''); ?></div>
    
    				<div class="clear"></div>
    
    				<?php wp_link_pages( array( 'before' => '<div class="nextpage"><span>' . __( 'Pages:', 'wpzoom' ) . '</span>', 'after' => '</div><div class="clear"></div>' ) ); ?>
    
    				<?php if (option::get('post_tags') == 'on') {  the_tags( __( '<div class="tag-list">Tags: ', 'wpzoom' ), ", ", "</div>\n" ); } ?>
    				<div class="clear"></div>
    			</div>
    
    			<?php
    			if ( option::get('post_share') == 'on' ) {
    
    				?><div class="share">
    
    					<h3><?php _e('Share this post', 'wpzoom'); ?></h3>
    
    <ul>
    <li><a href="http://twitter.com/share">" class="twitter-share-button" data-count="horizontal">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></li>
    <li><iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=button_count&show_faces=false&width=1000&action=like&font=arial&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe></li>
    <li><g:plusone size="medium"></g:plusone></li>
    </ul>
    <div class="clear"></div>
    
    				</div> <!-- /#share --><?php
    
    			}
    
    			if ( option::get('post_next') == 'on' ) {
    
    				?><div class="prevnext">
    
    					<?php
    					$previous_post = get_previous_post();
    					$next_post = get_next_post();
    
    					if ( $previous_post != NULL ) {
    
    						?><div class="previous">
    							<h3><?php _e('Previous Article', 'wpzoom'); ?></h3>
    							<a>ID); ?>" title="<?php echo $previous_post->post_title; ?>">← <?php echo $previous_post->post_title; ?></a>
    						</div><?php
    
    					}
    
    					if ( $next_post != NULL ) {
    
    						?><div class="next">
    							<h3><?php _e('Next Article', 'wpzoom'); ?></h3>
    							<a>ID); ?>" title="<?php echo $next_post->post_title; ?>"><?php echo $next_post->post_title; ?> →</a>
    						</div><?php
    
    					}
    					?>
    
    				</div><!-- /.nextprev --><?php
    
    			}
    			?>
    
    			<div id="comments">
    
    				<?php comments_template(); ?>
    
    			</div> <!-- /#comments --><?php
    
    		endwhile;
    
    	else:
    
    		?><p><?php _e('Sorry, no posts matched your criteria.', 'wpzoom');?></p><?php
    
    	endif;
    	?>
    
    </div> <!-- /#content -->
    </div>
    
    	<div class="fourcol last">
    
    <?php if ($template != 'full') {
    	get_sidebar();
    } ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Fields’ is closed to new replies.