Need help with Code Correction php+wordpress

I see that you try to make some buttons with the links of the previous and the next publication, wordpress has many ways to get those links with functions, I will show you 4:

// You are two functions print a tag with its respective link

// Previous publication
get_previous_post_link();
// Next post
get_next_post_link();

With this function you get the WP_Post object of the previous and next publications and you can get the URL easily in this way:

// get the previous WP_Post object
$prev = get_previous_post();

// get the previous WP_Post object
$next = get_next_post();

// With the function get_permalink () and passing the property ID of the
// variable $prev or $next that have the object, we retrieve
// the URL of the previous or next link.

echo get_permalink( $prev->ID );
echo get_permalink( $next->ID );

Examples of use:

echo '<a href="' esc_url( get_permalink( $prev->ID ) ) . '">Previous Post</a>';
echo '<a href="' esc_url( get_permalink( $next->ID ) ) . '">Next Post</a>'; 

I hope this is what you need.

https://developer.wordpress.org/reference/