1 回答

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超4個(gè)贊
如果你想在你的帖子的 single.php 中編輯 wordpress 帖子導(dǎo)航,你可以使用:
<span> <?php previous_post_link( '%link', '? Previous article' ); ?> </span>
<span> <?php next_post_link( '%link', 'Next article ?' ); ?> </span>
如果你想通過(guò)設(shè)置'next_text'來(lái)實(shí)現(xiàn)它,你也可以將你的輸出放在一個(gè)字符串中并使用它:
<?php $next_post = '<span>Previous article</span>'; ?>
然后將其分配給“next_text”:
'next_text' => $next_post
如果您閱讀 sprintf() 函數(shù)https://www.w3schools.com/php/func_string_sprintf.asp ,您可以毫無(wú)問(wèn)題地添加 html 標(biāo)簽。所以它也可以用于:
'next_text' => sprintf( esc_html__( '%s', 'mytheme' ), '<span> %title </span>' ),
但是你不想擁有這個(gè)頭銜,所以你實(shí)際上不需要這個(gè),如果我沒(méi)問(wèn)錯(cuò)的話。
編輯:
如果你想在你的帖子名稱前顯示跨度,你可以使用:
<?php previous_post_link( '%link', '<span>Previous article</span>'.' %title' ); ?>
用點(diǎn) . 您正在將 span 元素與標(biāo)題連接起來(lái)。
所以在你的代碼中,你的 the_post_navigation 看起來(lái)像:
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 關(guān)注
- 127 瀏覽
添加回答
舉報(bào)