Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //ループ内に書く
$previous_post = get_previous_post();
$next_post = get_next_post();
$prev_value = get_post_meta( $previous_post->ID, 'CUSTOM_FIELD', $single = true); //CUSTOM_FIELDが表示したいカスタムフィールドの名前
$next_value = get_post_meta( $next_post->ID, 'CUSTOM_FIELD', $single = true);
?>
<?php if ( $prev_value != '' ) : ?>
<p><?php echo $prev_value; ?></p><!--ここに前の記事に与えたCUSTOM_FIELDという名前のカスタムフィールドの値が表示される-->
<p><?php echo $next_value; ?></p><!--ここは次の記事-->
<?php endif; ?>
<?php //ループ内に書く
$previous_post = get_previous_post();
$next_post = get_next_post();
$prev_value = get_post_meta( $previous_post->ID, 'CUSTOM_FIELD', $single = true); //CUSTOM_FIELDが表示したいカスタムフィールドの名前
$next_value = get_post_meta( $next_post->ID, 'CUSTOM_FIELD', $single = true);
?>
<?php if ( $prev_value != '' ) : ?>
<p><?php echo $prev_value; ?></p><!--ここに前の記事に与えたCUSTOM_FIELDという名前のカスタムフィールドの値が表示される-->
<p><?php echo $next_value; ?></p><!--ここは次の記事-->
<?php endif; ?>
Note