Search code examples
phpif-statementquotes

How to display quote marks within an If statement


I have the below code with a shortcode for a contact form within an if statement, but the contact form doesn't show. I think its because I have displayed quote marks in the wrong place, but i'm a bit confused as to where they should go

My code is:

<?php 

if ($postid == "page-international.php" or $postid == "page-international-training.php" or $postid == "page-international-courses.php" or $postid == "page-international-training-course-detail.php") {
echo "<div class='get-ebook'><img class='close-ebook' src='https://www.pescado.co.uk/wp-content/themes/entyce/images/close-button-get.png' /><p class='title'><strong>Is your <br>scaffolding safe?</strong></p><span class='img'><img src='http://dev14.entycestudio.co.uk/wp-content/themes/custom/images/get-ebook.png' />

</span><?php echo do_shortcode('[contact-form-7 id='6664' title='ebook']' ); ?>

</div>";

} else {
echo "";
}

?>

If anyone could help, or point me in the right direction, it would be greatly appreciated :-)

Thanks


Solution

  • your problem might be the fact you have do_shortcode in a echo ""; try removing it from there. like so

      echo "<div class='get-ebook'><img class='close-ebook' 
      src='https://www.pescado.co.uk/wp-content/themes/entyce/images/close-
      button-get.png' /><p class='title'><strong>Is your <br>scaffolding
      safe?</strong></p><span class='img'><img 
      src='http://dev14.entycestudio.co.uk/wp-content/themes/custom
      /images/get-ebook.png' />
    
      </span>";echo do_shortcode('[contact-form-7 id="6664" title="ebook"]' ); 
    
      echo "</div>";
    
      } else {
      echo "";
        }