Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.