【问题标题】:Missing anchor tag in wordpress postwordpress 帖子中缺少锚标记
【发布时间】:2013-06-27 12:39:02
【问题描述】:

有没有办法使用 the_excerpt 在帖子中显示锚点或链接。在 wordpress 编辑器中,我在帖子的开头放置了一个锚标记。当我查看全文时,它可以正常工作。但是使用摘录时不起作用。

这是帖子的图片。我什至强调了这个词

http://i255.photobucket.com/albums/hh140/testament1234/anchortag_zpsf77fbef2.jpg

这是我检查视图源时的代码。如您所见,链接 facebook.com 变成了一个段落,而不是一个锚链接。

   <div class="content">
              <!--TEXT -->
              <p>www.facebook.com Nullam dictum eleifend neque facilisis pellentesque. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur cursus mollis tincidunt. Donec tincidunt, augue ullamcorper pharetra porta, metus turpis volutpat urna, nec [...]</p>


             <a class="readmore" href="http://localhost/wordpress/sample-post-14/"><span>Full Article</span></a>
       </div>

我该如何解决这个问题?如果我将 the_excerpt 替换为 the_content,它将显示该帖子的内容。

【问题讨论】:

  • 我们可以看看你的 the_excerpt 代码吗?

标签: wordpress content-management-system anchor


【解决方案1】:

问题在于,默认情况下,_excerpt 函数会禁用所有 HTML 标记。这就是为什么所有链接都消失了。

您可能需要自定义由_excerpt 函数返回的内容并允许例如链接标签。 This tutorial 告诉你如何做到这一点。

【讨论】:

  • 代码似乎不能完美运行嗯。可能会尝试对我的代码进行一些小改动
【解决方案2】:
echo $post->post_excerpt; // this will return you the excerpt of the current post

【讨论】:

  • 谢谢,您的解决方案存在问题,用户必须在我们的锚点标签摘录中包含

    标签,但我想这是目前唯一的方法

  • 您可以在摘录中插入任何内容
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-06-21
  • 1970-01-01
  • 1970-01-01
  • 2010-12-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多