How to php if else statement and return different divs? -
i'm trying create if-else statement, return different divs. believe failing because there many '
in else statement.
<?php $blogentryid = get_the_id(); if ($blogentryid=="1572") { echo '<div>hello</div>' } else { echo '<div class="socialnews2"><!-- start div social--> <div class="twitternews2"> <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="<?php the_title(); ?>" d ata-url="<?php the_permalink() ?>" data-via="giantmangocom">tweet</a> <script type="text/javascript"> //async script, twitter button fashiolista.com style (function() { var s = document.createelement('script'); var c = document.getelementsbytagname('script')[0]; s.type = 'text/javascript'; s.async = true; s.src = 'http://platform.twitter.com/widgets.js'; c.parentnode.insertbefore(s, c); })(); </script> </div> </div> <div class="facebooknews2"> <iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->id)); ?>&layout=button_count& amp;show_faces=false&width=80&action=like&colorscheme=light;height=21"" scrolling="no" frameborder="0" style="border:none; overflow:hidden; wid th:80px; height:21px;" allowtransparency="true"></iframe> </div>' } ?>
when want show conditional content, open , close <?php
tags instead of using echo statements.
<?php if ($blogentryid == "1572") { ?> <div>hello</div> <?php } else { ?> <div class="socialnews2"><!-- start div social--> ... rest of content here <? } ?>
it ensure php code inside of div gets evaluated intended.
Comments
Post a Comment