functions.php
チャイルドテーマのfunctions.phpに以下のPHPコードを追加
function raindrops_prev_next_post( $position= "nav-above" ) {
$previous_image = '';
$next_image = '';
if ( is_category() ) {
$filter= true; //display same category.
} else {
$filter= false;
}
if ( !is_single() ) {
return $original;
} else {
$previous = get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( has_post_thumbnail( $previous->ID ) ) {
$previous_image= get_the_post_thumbnail( $previous->ID, array( 48, 48 ) );
}
if ( has_post_thumbnail( $next->ID ) ) {
$next_image= get_the_post_thumbnail( $next->ID, array( 48, 48 ) );
}
}
//exclude separate 'and'
$exclude_category = apply_filters( 'raindrops_next_prev_excluded_categories', '' );
$html = '<div id="%1$s" class="%2$s"><span class="%3$s">';
printf( $html, $position, "clearfix", "nav-previous" );
previous_post_link( '%link', $previous_image . '<span class="button"><span class="meta-nav">«</span> %title</span>', $filter, $exclude_category );
$html = '</span><div class="%1$s">';
printf( $html, "nav-next" );
next_post_link( '%link', '<span class="button"> %title <span class="meta-nav">»</span></span>' . $next_image, $filter, $exclude_category );
$html = '</div></div>';
echo apply_filters( "raindrops_prev_next_post", $html );
}
CSS
チャイルドテーマのstyle.css
又は、
カスタマイズ/高度な設定/サイトワイドCSSに追加
.single #nav-below{
margin-top:1em;
position:relative;
}
.single .nav-next .button{
margin-right:50px;
}
.single .nav-previous .button{
margin-left:50px;
}
.single .nav-next a:after,
.single .nav-previous a:before{
display:none;
}
.single .nav-next img{
position:absolute;
right:0;
}
.single .nav-previous img{
position:absolute;
left:0;
}
