Here’s where the post navigation code lives in “content-single.php”:
<?php if ( ! get_theme_mod( 'new_standard_hide_post_nav' ) ) : ?> <?php new_standard_post_nav(); ?><?php endif; ?><?php if ( is_active_sidebar( 'after-post' ) ) : ?> <?php dynamic_sidebar( 'after-post' ); ?><?php endif; ?>
And here’s where that lives in the theme’s function files:
if ( ! function_exists( 'new_standard_post_nav' ) ) :
/**
* Display navigation to next/previous post when applicable.
*/
function new_standard_post_nav() {
// Don't print empty markup if there's nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next && ! $previous ) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'new-standard' ); ?></h1>
<div class="nav-links">
<?php
previous_post_link( '<div class="nav-previous"><div class="post-nav-title">' . __( 'Older post', 'new-standard' ) . '</div>%link</div>', _x( '%title', 'Previous post link', 'new-standard' ) );
next_post_link( '<div class="nav-next"><div class="post-nav-title">' . __( 'Newer post', 'new-standard' ) . '</div>%link</div>', _x( '%title', 'Next post link', 'new-standard' ) );
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
endif;
I’m a bit of a novice with PHP so I appreciate any guidance or help.
]]>How can we loop the previous and next post block’s functionality so instead of getting to the lat post and ending, it loops back to the first post?
Or if this is not possible, can we at least display either control when it disappears at the first or last post as an inactive UI element? I’ve tried with CSS but nothing’s working (so far), but maybe I’ve not done this completely right. I’ll paste the code I’ve tried for this fall back solution but any information or ideas appreciated, thank you!
/* Show the previous post navigation link at all times */
.wp-block-post-navigation__prev-link {
display: block !important;
}
/* Adjust the styling of the inactive previous post navigation link */
.wp-block-post-navigation__prev-link.inactive {
opacity: 0.5;
/* Additional styling properties here */
}
/* Show the previous post navigation link at all times */
.post-navigation-link-previous {
display: block !important;
}
/* Adjust the styling of the inactive previous post navigation link */
.post-navigation-link-previous.inactive {
opacity: 0.5;
/* Additional styling properties here */
}
]]>Why is the page navigation not working?
]]>Is there a way the previous and next arrows can be displayed on the box BEFORE one cursors over them so that it is clear what the boxes are?
Thanks for the work you did to create the plug-in and for your assistance on my inquiry.
R. Jones
]]>I’m using TranslatePress on a website I’m building for a client who wants a bilingual website. So far it’s working great except that I just noticed a weird thing missing.
Whenever I change from the default (Dutch) to English the arrows I’ve added for post navigation on blogposts as well as portfolio posts disappear. The whole div is just not existing anymore as far as I can see.
I’ve tried various settings and disabling plugins already.
It seems that also the back-to-top button that is added through a plugin is malfunctioning, though that’s not my main issue at the moment. The arrows should really stay put whenever I translate a page!
Appreciate any help
nav.navigation.post-navigation { display: none; }
</p><!– wp:paragraph –>
<p>The code only works inside the Elementor editor. Even when publishing and updating it doesn’t show up online.</p>
<!– /wp:paragraph –>
<!– wp:paragraph –>
<p>I just want to disable the navigation or be able to move it.</p>
<!– /wp:paragraph –>
I created a custom loop in Elementor Pro. Even though I select sort by date and even though I tried ascending and decending, nothing happens. Only changing the post order manually (working with Post types Order plugin here) has an effect.
I cannot change the order manually though, as the Elementor Post navigation widget somehow works only on this basis and I need it to stay the way it is.
The Loop and the post navigation work in reverse directions now.
Loop shows 2020, 2021, 2022 from left to right
Post navigation points left to the latest year 2022 and right to the oldest 2020, which is what I want. This is really confusing for the user.
Hope someone can help.
Thanks, Mara
]]>