Search code examples
phpwordpresswordpress-themingcontact-form-7custom-wordpress-pages

the contact form 7 is not in my wordpress site? but works on a blank page some issues with my code


the contact form 7 is not in my wordpress site? but works on a blank page some issues with my code. when i paste the short code in my Contact page it dosent show up. i have done my html and css code built i have also used bootstrap 4.5 code contact page code

<?php
    get_header();  
    $thumbnail_url = wp_get_attachment_url(get_post_thumbnail_id($post -> ID)); 
?>
<?php
    if(has_post_thumbnail()){ ?>
        <section class="about"  style="background: url('<?php echo $thumbnail_url; ?>') no-repeat; background-size: cover;">
           <div class="hero-text w-100 text-white px-2 px-sm-0">
               <h1 class="display-3 brand"><?php echo the_title(); ?></h1>
               <p class="lead"><?php echo the_excerpt();   ?></p>
           </div>
        </section>
    <?php } else{   ?>
          <section class="about">
              <div class="hero-text w-100 text-white px-2 px-sm-0">
                  <h1 class="display-3 brand"><?php echo the_title(); ?></h1>
                  <p class="lead"><?php echo the_excerpt(); ?></p>
              </div>
          </section>
    <?php } ?>
<?php
    get_footer();
?>

Solution

  • It looks like you should use the_content instead of the_excerpt - shortcodes will be executed in this case.

    <h1 class="display-3 brand"><?php the_title(); ?></h1>
    <p class="lead"><?php the_content(); ?></p>
    

    But if you need excerpt with shortcodes, use

    apply_shortcodes(get_the_excerpt());
    

    In this case there is a possibility you shortocde will be sliced due to excerpt length limits