簡體   English   中英

修改php以獲取“閱讀更多”文本以鏈接到特定的WordPress頁面

[英]Modify php for 'read more' text to link to a specific WordPress page

我正在嘗試修改WordPress插件中的“更多內容”以鏈接到特定頁面,而不是默認的帖子。 在這種情況下,它是推薦插件的一部分。

我已經找到了將以下代碼添加到主題functions.php文件末尾並修改$more_text變量的說明,但是我不確定應該在何處添加頁面ID或url,以及是否應替換任何現有的代碼段。 這是代碼-

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

有什么建議么?

您可以在href中放入新鏈接。

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

您可以添加靜態鏈接,例如:

$more_text = '... <a class="read-more" href="http://www.stackoverflow.com/">Read the Rest...</a>';

或者,您可以像示例中那樣生成一個鏈接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM