修改php以获取“阅读更多”文本以链接到特定的WordPress页面

时间:2016-10-31 03:19:52

标签: php wordpress variable-assignment

我正在尝试修改WordPress插件中的“Read More”以链接到特定页面,而不是默认等效的帖子。在这种情况下,它是推荐插件的一部分。

我找到了将以下代码添加到主题functions.php文件末尾并修改$more_text变量的说明,但我不确定应添加页面ID或网址的位置以及是否它应该替换任何现有的代码段。这是代码 -

function hg_testimonial_rotator_the_excerpt( $html, $limit )
{
    $more_text = '... <a class="read-more"    href="'.get_permalink(get_the_ID()).'">Read the Rest...</a>';
    return wp_trim_words(get_the_excerpt(), $limit, $more_text);
}
add_filter('testimonial_rotator_the_excerpt',    'hg_testimonial_rotator_the_excerpt', 10, 2);

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

在a href中,您可以添加新链接。

parse: (resp, xhr) ->
      return resp.toJSON()
    )

您可以添加静态链接,例如:

$more_text = '... <a class="read-more" href="here goes your new link">Read the Rest...</a>';

或者您可以生成类似示例的链接。