Is there a way to add the previous/nest post arrows to a custom post type post? I’ve added the <?php x_entry_navigation(); ?> code to my custom post type single posts, but it’s not showing on the front end.
I’m using the following code in my child theme functions.php file to customize the arrows and move them to the bottom of the post page, but I can’t figure out how to get them to work on my custom post type posts.
function x_entry_navigation() {
$stack = x_get_stack();
if ( $stack == 'ethos' ) {
$left_icon = '<i class="x-icon-chevron-left" data-x-icon=""></i> PREV';
$right_icon = 'NEXT <i class="x-icon-chevron-right" data-x-icon=""></i>';
} else {
$left_icon = '<i class="x-icon-arrow-left" data-x-icon=""></i>';
$right_icon = '<i class="x-icon-arrow-right" data-x-icon=""></i>';
}
$is_ltr = ! is_rtl();
$prev_post = get_adjacent_post( true, '', false );
$next_post = get_adjacent_post( true, '', true );
$prev_icon = ( $is_ltr ) ? $left_icon : $right_icon;
$next_icon = ( $is_ltr ) ? $right_icon : $left_icon;
?>
<div class="x-nav-articles">
<?php if ( $prev_post ) : ?>
<a href="<?php echo get_permalink( $prev_post ); ?>" title="<?php __( 'Previous Post', '__x__' ); ?>" class="prev">
<?php echo $prev_icon; ?>
</a>
<?php endif; ?>
<?php if ( $next_post ) : ?>
<a href="<?php echo get_permalink( $next_post ); ?>" title="<?php __( 'Next Post', '__x__' ); ?>" class="next">
<?php echo $next_icon; ?>
</a>
<?php endif; ?>
</div>
<?php
}
add_action( 'x_after_the_content_end', 'x_print_nav', 999 );
function x_print_nav(){
if(is_singular( 'post' )){
x_entry_navigation();
}
}
The div is added in the correct place, but it’s empty with no nav arrows. Is there a way to revise this code to work on custom post types?