add_filter( 'next_post_link', 'my_adjacent_post_link', 10, 5 ); add_filter( 'previous_post_link', 'my_adjacent_post_link', 10, 5 ); function my_adjacent_post_link( $output, $format, $link, $post, $adjacent ) { $previous = 'previous' === $adjacent; if ( ! ( $previous && is_attachment() ) ) { $post = get_adjacent_post( true, '', $previous, 'category' ); } if ( ! $post ) { $output = ''; } else { $title = $post->post_title; if ( empty( $post->post_title ) ) { $title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); } $title = apply_filters( 'the_title', $title, $post->ID ); $date = mysql2date( get_option( 'date_format' ), $post->post_date ); $rel = $previous ? 'prev' : 'next'; $string = ''; $inlink = str_replace( '%title', $title, $link ); $inlink = str_replace( '%date', $date, $inlink ); $inlink = $string . $inlink . ''; $output = str_replace( '%link', $inlink, $format ); } return $output; }
Show Info

©2025 Peter Walberg

Vector

Huh

By PWalberg · September 28, 2021

Huh 2021