Jump to content

content to be conditionally displayed or not


hopeinthecloud

Recommended Posts

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>

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>

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>';
		 	} ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.