1 回答

TA貢獻1810條經驗 獲得超4個贊
如果你想在你的帖子的 single.php 中編輯 wordpress 帖子導航,你可以使用:
<span> <?php previous_post_link( '%link', '? Previous article' ); ?> </span>
<span> <?php next_post_link( '%link', 'Next article ?' ); ?> </span>
如果你想通過設置'next_text'來實現它,你也可以將你的輸出放在一個字符串中并使用它:
<?php $next_post = '<span>Previous article</span>'; ?>
然后將其分配給“next_text”:
'next_text' => $next_post
如果您閱讀 sprintf() 函數https://www.w3schools.com/php/func_string_sprintf.asp ,您可以毫無問題地添加 html 標簽。所以它也可以用于:
'next_text' => sprintf( esc_html__( '%s', 'mytheme' ), '<span> %title </span>' ),
但是你不想擁有這個頭銜,所以你實際上不需要這個,如果我沒問錯的話。
編輯:
如果你想在你的帖子名稱前顯示跨度,你可以使用:
<?php previous_post_link( '%link', '<span>Previous article</span>'.' %title' ); ?>
用點 . 您正在將 span 元素與標題連接起來。
所以在你的代碼中,你的 the_post_navigation 看起來像:
the_post_navigation( array(
/* translators: %s: title syntax. */
'prev_text' => sprintf( esc_html__( '%s', 'mytheme' ), '<span>Previous article</span>'.' %title' ),
/* translators: %s: title syntax. */
'next_text' => sprintf( esc_html__( '%s', 'mytheme' ), '<span>Next article</span>'.' %title' ),
) );
- 1 回答
- 0 關注
- 143 瀏覽
添加回答
舉報