Created
June 26, 2019 10:06
-
-
Save Nikschavan/01f81d4d11633a092e202a4b578697fe to your computer and use it in GitHub Desktop.
Astra Post navigation with featured image
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 | |
/** | |
* Function to change the Next Post/ Previous post text. | |
* | |
* @param array $args Arguments for next post / previous post links. | |
* @return array | |
*/ | |
function astra_change_next_prev_text( $args ) { | |
$next_post = get_next_post(); | |
$prev_post = get_previous_post(); | |
$next_text = false; | |
if ( $next_post ) { | |
$next_text = sprintf( | |
'%s <span class="ast-right-arrow">→</span> %s', | |
$next_post->post_title, | |
get_the_post_thumbnail( $next_post, 'small' ) | |
); | |
} | |
$prev_text = false; | |
if ( $prev_post ) { | |
$prev_text = sprintf( | |
'<span class="ast-left-arrow">←</span> %s %s', | |
$prev_post->post_title, | |
get_the_post_thumbnail( $prev_post, 'small' ), | |
); | |
} | |
$args['next_text'] = $next_text; | |
$args['prev_text'] = $prev_text; | |
return $args; | |
} | |
add_filter( 'astra_single_post_navigation', 'astra_change_next_prev_text' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment