hopeinthecloud Posted March 28, 2010 Share Posted March 28, 2010 Hi, I am new to php tonight and I am customizing a WordPress website. I have found how to properly create an if statement and I have two statements included (getImage() and the_content()) but I don't know how to include the 'Read More' link inside the condition. Could someone help me with the syntax please? Thank you. <div class="storycontent"> <?php if($i == 2) { getImage('1'); echo the_content(); } ?> <div class="contread"><a href="<?php the_permalink(); ?>">Read More »</a></div> </div> Link to comment https://forums.phpfreaks.com/topic/196744-content-to-be-conditionally-displayed-or-not/ Share on other sites More sharing options...
dreamwest Posted March 28, 2010 Share Posted March 28, 2010 wheres the function "the_permalink();"? usually a function will use return $var; so you will still need to echo it <div class="storycontent"><?php if($i == 2) { getImage('1'); echo the_content();} ?><div class="contread"><a href="<?php echo the_permalink(); ?>">Read More »</a></div></div> Link to comment https://forums.phpfreaks.com/topic/196744-content-to-be-conditionally-displayed-or-not/#findComment-1032916 Share on other sites More sharing options...
hopeinthecloud Posted March 28, 2010 Author Share Posted March 28, 2010 Thank you Dreamwest. It took me only a few minutes to understand what you were getting at with echoing but I got it. The following is how I changed things and it works like I wanted. Thank you. <?php if($i == 2) { getImage('1'); echo the_content(); echo '<div class="contread"><a href="'; echo the_permalink(); echo '">Read More »</a></div>'; } ?> Link to comment https://forums.phpfreaks.com/topic/196744-content-to-be-conditionally-displayed-or-not/#findComment-1033029 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.