Back Button
我将@ItsMePN答案与WordPress如何处理错误页上的后页相结合-
wp_die
. 它是
JavaScript.
onclick=\'javascript:history.back()\'
https://core.trac.wordpress.org/browser/tags/4.4.2/src/wp-includes/functions.php#L2537
添加到主题中
functions.phpadd_action( \'back_button\', \'wpse221640_back_button\' );
function wpse221640_back_button()
{
if ( wp_get_referer() )
{
$back_text = __( \'« Back\' );
$button = "\\n<button id=\'my-back-button\' class=\'btn button my-back-button\' onclick=\'javascript:history.back()\'>$back_text</button>";
echo ( $button );
}
}
添加到主题
header.php 之后
<body>
<?php do_action(\'back_button\'); ?>