Plugin Support
Jeremy
(@jeremrm)
Hello @porshegt9,
Thank you so much for getting in touch.
What you’re experiencing is actually the expected behavior. In Rank Math, the %page% variable automatically includes a separator when it’s output on the frontend, which is why you’re seeing the extra “–” before the pagination text.
To avoid this and have more control over the output, you can use a custom variable instead of %page%. You can add the following filter to your site:
add_action('rank_math/vars/register_extra_replacements', function () {
rank_math_register_var_replacement(
'custom_page',
[
'name' => esc_html__('Author name', 'rank-math'),
'description' => esc_html__('Author description', 'rank-math'),
'variable' => 'custom_page',
'example' => custom_page_call_back(),
],
'custom_page_call_back'
);
});
function custom_page_call_back() {
if (is_paged()) {
global $wp_query;
$current = max(1, get_query_var('paged'));
$total = max(1, $wp_query->max_num_pages);
return sprintf(
esc_html__('Page %1$s of %2$s', 'rank-math'),
$current,
$total
);
}
return '';
}
Once added, you can replace %page% with %custom_page% in your title or description settings.
You may refer to this guide for adding custom code to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Let us know how that goes.
Hello @porshegt9,
Since we have not heard back from you, we are going to close this thread for now. If you still need any assistance, please feel free to reopen this thread or create a new one, and we will be happy to help.
Thank you.