首页 > 解决方案 > 联系表格 7 不在我的 wordpress 网站中?但在空白页上工作我的代码有一些问题

问题描述

联系表格 7 不在我的 wordpress 网站中?但在空白页上工作我的代码有一些问题。当我将短代码粘贴到我的联系人页面时,它不会出现。我已经完成了我的 html 和 css 代码构建我还使用了 bootstrap 4.5 代码 联系页面代码

<?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();
?>

标签: phpwordpresswordpress-themingcontact-form-7custom-wordpress-pages

解决方案


看起来您应该使用the_content而不是the_excerpt- 在这种情况下将执行短代码。

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

但是,如果您需要带有简码的摘录,请使用

apply_shortcodes(get_the_excerpt());

在这种情况下,由于摘录长度限制,您的短代码可能会被切片


推荐阅读