Overview…
I wanted to customise the standard Astra post navigation labels (next/previous) on single blog posts, replacing the default “Previous Post” and “Next Post” text with custom labels. Easy enough with a documented code snippet… or was it?
Goal…
Replace the default Astra single post navigation strings with custom labels — “Next Article →” and “← Previous Article” — while keeping the linked post title displayed beneath each label, matching the existing front-end layout.
First Attempt: Default Strings (Per Astra Documentation)…
Astra’s documentation (astra_default_strings filter) suggested the following approach where I just switched out ‘Post’ for ‘Article’:
function bmcs_search_strings_callback( $strings ) {
$strings['string-single-navigation-next'] = __( 'Next Article %s', 'astra' ) . ' <span class="ast-right-arrow" aria-hidden="true">→</span>';
$strings['string-single-navigation-previous'] = '<span class="ast-left-arrow" aria-hidden="true">←</span> ' . __( 'Previous Article %s', 'astra' );
return $strings;
}
add_filter( 'astra_default_strings', 'bmcs_search_strings_callback', 20 );
This did not work for the navigation strings despite working correctly for other strings in the same function (search placeholder, 404 subtitle, nothing-found messages).
Troubleshooting…
Several approaches were tested without success:
- Confirmed the filter was firing — other strings within the same callback updated correctly on the front end.
- Verified the string keys against
astra/inc/class-theme-strings.phpin the parent theme. - Increased filter priority from
10to20to ensure it ran after Astra’s own registration. - Removed
__()wrappers and%splaceholders to rule outsprintfinterference.
None of these resolved the issue. The astra_default_strings filter is unreliable specifically for the post navigation strings — Astra processes these via a dedicated filter (astra_single_post_navigation) rather than pulling from the default strings array at render time.
Second Attempt: Astra Post Navigation (Per Astra Documentation)…
Having figured out there was a filter, I found the documentation ‘How to Change Previous and Next Link Text from a Single Blog Post?‘. Copy & Paste… not quite.
The documentation offers up two solutions:
- Replace default navigation strings with next/previous post titles
- Replace default navigation strings with custom text
Whilst they both work as intended, unfortunately they just update the actual link text (and omit the label), so in isolation they do not solve my need for maintaining the default format.
The Solution…
Update the astra_single_post_navigation filter to provide full control over both the label text and the post title markup:
add_filter( 'astra_single_post_navigation', 'bmcs_change_next_prev_text' );
function bmcs_change_next_prev_text( $args ) {
$next_post = get_next_post();
$prev_post = get_previous_post();
if ( $next_post ) {
$args['next_text'] = sprintf(
'Next Article <span class="ast-right-arrow" aria-hidden="true">→</span><span class="nav-title"><p>%s</p></span>',
$next_post->post_title
);
}
if ( $prev_post ) {
$args['prev_text'] = sprintf(
'<span class="ast-left-arrow" aria-hidden="true">←</span> Previous Article<span class="nav-title"><p>%s</p></span>',
$prev_post->post_title
);
}
return $args;
}
Add to your child theme functions.php. Simply update the Next Article / Previous Article text for your own custom text.
The <p> tags wrap the post title inside the %s placeholder within the format string, matching Astra’s native markup output.
Key Takeaways…
astra_default_stringsworks for most Astra UI strings but is not reliable for single post navigation labels — don’t waste time debugging priority or key names.astra_single_post_navigationis the correct hook for next/previous link customisation, regardless of what theastra_default_stringsdocumentation implies.- The Astra docs present
astra_single_post_navigationas an either/or choice (post title or custom text) — combining both in a singlesprintf()format string is straightforward and not documented (that I could find). - HTML elements (e.g.
<p>) belong inside thesprintfformat string alongside the%stoken, not concatenated around the PHP variable.
