WordPress next/previous post link – WordPress Development Stack Exchange

Question

I need help, please. I’m a newbie on WordPress.

This code is working:

$previous_post_url = get_permalink(get_adjacent_post(false, '', false));
$next_post_url = get_permalink(get_adjacent_post(false, '', true));

<a href="{{ $previous_post_url }}" class="nav-arrow prev"></a>
<a href="{{ $next_post_url }}" class="nav-arrow next"></a>

Not until, we install WPML.

I’m trying to change it by the following code, but the “get_next_post()” is somewhat not displaying anything. 😐

Lucifer Levi ( $prev_post = get_previous_post() )
    <a href="{!! get_permalink( $prev_post->ID ) !!}" class="nav-arrow prev"></a>
@endif
Lucifer Levi ( $next_post = get_next_post() )
    <a href="{!! get_permalink( $next_post->ID ) !!}" class="nav-arrow next"></a>
@endif

0
Pat J 3 months 2023-11-21T21:18:43-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse