Conditional tag if $customfield exists
-
I am creating the page.php template for a new wordpress theme. When the custom field $post-image is included in the page, I want it to display with 2 columns where the $post-image is in the left column and the content is in the right column. When the $post-image does not display, I want the content to display in a div of the full width of the page.
https://mandabee.com/wordpress/
https://mandabee.com/wordpress/aboutSee how on the index page the $post-image is included and the content displays how I’d like; however, on the about page there is no input for the $post-image, but yet the content is still displaying with the two columns. The code I have so far is:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php if ( $post-image ) { ?>
<div class=”left”>
<img src=”<?php echo get_post_meta($post->ID, ‘post-image’, true); ?>” alt=”Image for Page #<?php the_ID(); ?>” />
</div><div class=”right”>
<?php } else { ?>
<div class=”post”><h2>“><?php the_title(); ?></h2>
<?php } ?><div class=”entry”>
<?php the_content(); ?>
</div></div>
<?php endwhile; else: ?><p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
Thanks!
- The topic ‘Conditional tag if $customfield exists’ is closed to new replies.