PHP if statement for custom fields.
-
Hello,
I’m trying to create a PHP “if” statement that places the data from custom fields into a div with css, but if there are no custom fields applied to that post, then the div is displayed with static text.Here’s what I have right now:
<?php if(the_meta()): ?> <div id="portfolio-meta"> <p id="projmeta-head">Project Information:</p> <?php the_meta(); ?> </div> <?php else: ?> <div id="portfolio-meta"> <p id="projmeta-head-negative">This item has no information associated with it. Sorry.</p> </div> <?php endif; ?>
However, when wordpress comes across a post with custom fields, instead of displaying the div with the meta data in it, the div under “else” is displayed, and the metadata is displayed above the div.
What’s wrong with this picture? Also, I’m very new at writing PHP, so this is my attempt at trying to figure things out after doing some research.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘PHP if statement for custom fields.’ is closed to new replies.