首页 > 解决方案 > 如何在 Wordpress 博客视图页面上显示链接

问题描述

我正在开发基于 Wordpress 的网站并尝试在 Wordpress 博客视图页面上显示链接(请参阅此处的页面),但链接会自动转换为纯文本。我试过这段代码但没有成功:

<?php
function keep_my_links($text) {
  global $post;
if ( '' == $text ) {
    $text = get_the_content('');
    $text = apply_filters('the_content', $text);
    $text = str_replace('\]\]\>', ']]&gt;', $text);
    $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
    $text = strip_tags($text, '<a>');
  }
  return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'keep_my_links');
?>

谁能帮我解决这个问题?

标签: wordpress

解决方案


推荐阅读