What am I doing wrong? <?php if ( is_page('car-dealer-website')) { <a href=""> <img src="" border="0"> </a> } else { <img src="" border="0"> } ?> Code (markup):
if (is_page('car-dealer-website')) { echo "<a href=\"\"><img src=\"\" border=\"0\"></a>"; } else { echo "<img src=\"\" border=\"0\">"; } PHP:
@activeFrost, GREAT example of why using double quotes with ECHO is ***tarded. Also, in "modern" HTML there is no such thing as a BORDER attribute; unless you're crapping out HTML 3.2 and slapping 4 tranny or 5 lip-service on it, staying in 'transition' from 1997 to 1998 coding practices, you have NO business using BORDER, and there's another attribute called 'ALT' that is NOT OPTIONAL. If you were doing more than just outputting markup, I'd keep the if statement... <?php if ( is_page('car-dealer-website')) { echo '<a href=""><img src="" alt=""></a>'; } else { echo '<img src="" alt="">'; } ?> Code (markup): But if it was going to just be 'this has anchors, this doesn't" I'd use a inline eval instead... storing is_page's result in a var since that would likely be faster than calling the function twice. <?php echo ( ($isPage = is_page('car-dealer-website')) ? '<a href="">' : '' ),'<img src="" alt="" />',( $isPage ? '</a>' : '' ); ?> Code (markup):
Apart from them being slower (more so at the bytecode compile stage than exec) due to having to look for more things, the wasted time and effort of having to escape every time you want a double quote in the output (something that in HTML is REALLY common) -- I just don't get the infatuation (and resulting ugly code) with them certain PHP developers seem to have.