• I have a custom field called “taped_paper” . If I add the custom field to the post and enter “show” in the field, it should display the code below, if the custom field is not added, or is empty, it should show nothing.

    The problem is, when I have it set like this, the code ALWAYS shows no matter what I have filled out even if I delete the custom field.

    In my template I have this:

    <?php
    $key = 'taped_paper';
    $themeta = get_post_meta($post->ID, $key, TRUE);
    if($themeta = 'show') { ?>
    		<div id="single-portfolio-left">
    			<?php the_content(); ?>
                <div class="clear"></div>
    
                <div id="single-portfolio-meta" class="clearfix">
    				<ul>
                        <li><span><?php _e('Date','office'); ?>:</span><?php the_date('M Y'); ?></li>
    					<?php if($terms) { ?><li><span><?php _e('Labeled','office'); ?>:</span><?php echo get_the_term_list( get_the_ID(), 'portfolio_cats', '', ', ', ' ') ?></li><?php } ?>
                        <?php if(!empty($portfolio_cost)) {?><li><span><?php _e('Cost','office'); ?>:</span><?php echo $portfolio_cost; ?></li><?php } ?>
                        <?php if(!empty($portfolio_client)) {?><li><span><?php _e('Client','office'); ?>:</span><?php echo $portfolio_client; ?></li><?php } ?>
                        <?php if(!empty($portfolio_url)) {?><li><span><?php _e('Website','office'); ?>:</span><a href="<?php echo $portfolio_url; ?>"><?php echo $portfolio_url; ?></a></li><?php } ?>
                	</ul>
                </div>
                <!-- /single-portfolio-meta -->
            </div>
            <!-- /single-portfolio-left -->
    
    <?php } else { } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘trying to test if custom field is filled in and it's not working’ is closed to new replies.