输出WordPress时的额外<p>标签&#34;阅读更多&#34;链接

时间:2017-09-24 15:57:59

标签: php html wordpress

我写了一个输出变量博客文章的函数&#34; Read More&#34;链接,我刚刚注意到它还在最后呈现了一个额外的空<p>标记:

function new_excerpt_more( $more ) {
  global $post;
  if (is_page( '39' ) ) {
    return ' [&#8230;]<div id="blog-newest-continue"><a class="moretag btn btn-primary btn-xl wow bounceIn" href="'. get_permalink($post->ID) . '#post-content' . '">Continue reading <span>&rarr;</span></a></div>';
  }
   else {
    return ' [&#8230;]<div id="blog-newest-continue"><a class="moretag btn btn-primary btn-md" href="'. get_permalink($post->ID) . '">Continue reading <span>&rarr;</span></a></div>';
  }
}
add_filter('excerpt_more', 'new_excerpt_more');

呈现HTML:

<div class="col-lg-10 col-lg-offset-1 text-center">
 <h2 class="section-heading">Blog</h2>
 <h3><a href="http://localhost:8888/2016/06/hello-wordpress-world/">Text</a></h3>
 <header id="blog-newest-byline" class="post-byline">
  <div><span class="post-time"><i class="fa fa-fw fa-calendar-o"></i>Jun 2nd, 2016 at 16:18 EDT</span> <span class="post-tags"><i class="fa fa-fw fa-tags"></i> <a href="http://localhost:8888/tag/web-design/" rel="tag">web design</a>, <a href="http://localhost:8888/tag/web-development/" rel="tag">web development</a>, <a href="http://localhost:8888/tag/wordpress/" rel="tag">wordpress</a></span>   <span class="post-comments"><i class="fa fa-fw fa-comments-o"></i> <a href="http://localhost:8888/2016/06/hello-wordpress-world/#comments"><fb:comments-count href="http://localhost:8888/2016/06/hello-wordpress-world/" fb-xfbml-state="rendered" class=" fb_comments_count_zero"><span class="fb_comments_count">0</span></fb:comments-count>
   comments</a>
   </span>
  </div>
 </header>
 <div class="post-thumb row no-gutter"><a href="http://localhost:8888/2016/06/hello-wordpress-world/"><img width="700" height="700" src="http://localhost:8888/wp-content/uploads/2016/02/test.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt=""></a></div>
 <p
   id="blog-newest-excerpt">Text</p>
  <div id="blog-newest-continue"><a class="moretag btn btn-primary btn-xl wow bounceIn" href="#post-content" style="visibility: visible; animation-name: bounceIn;">Continue reading <span>→</span></a></div>
  <p></p>
</div>

我还注意到它只发生在主页(第39页)条件下,如果我将return留空,则没有额外的<p>标记。另外,我还使用remove_filter( 'the_content', 'wpautop' );从WYSIWYG编辑器中删除了额外的<p>标记。

可能导致这种情况的原因是什么?提前谢谢!

0 个答案:

没有答案