Back to Community

How to Fix Double Spaces and Formatting Issues with %%current_pagination%% in SEOPress Titles

7 threads Sep 9, 2025 PluginSeopress – on-site seo

Content

Users of the SEOPress – On-site SEO plugin sometimes encounter a formatting issue on the first page of archive listings (like categories or tags). The problem arises when using the %%current_pagination%% dynamic variable in title templates.

On paginated pages (page 2, 3, etc.), the title displays correctly. However, on page 1, where %%current_pagination%% outputs nothing, it can leave behind an unwanted double space before the separator (%%sep%%), making the title look unprofessional.

Why This Happens

The %%current_pagination%% variable is designed to be empty on the first page of an archive. When it's placed in a template like %%term_title%% %%current_pagination%% %%sep%% %%sitetitle%%, its empty value on page 1 results in two consecutive spaces between %%term_title%% and %%sep%%.

Solution: Clean Extra Spaces with a Code Snippet

The most effective solution is to add a small code snippet to your theme's functions.php file. This code will clean up any extra spaces caused by empty dynamic variables.

Step-by-Step Guide:

  1. Access your WordPress theme files, typically through your hosting provider's file manager or an FTP client.
  2. Locate your active theme's functions.php file. It is highly recommended to use a child theme to prevent your changes from being overwritten during theme updates.
  3. Open the functions.php file for editing.
  4. Paste the following code snippet at the very end of the file:

    function sp_titles_title($html)
    {
        // This function removes any extra spaces from the title
        $html = implode(' ', array_filter(explode(" ", $html)));
        return $html;
    }
    add_filter('seopress_titles_title', 'sp_titles_title');
  5. Save the changes and upload the file back to your server if necessary.

This code works by filtering the final title output. It explodes the title string into an array using spaces, filters out any empty array elements (like our empty variable), and then implodes the array back into a string with single spaces. This ensures a clean title without double spaces on page 1.

This solution, shared by the SEOPress team in a support thread, is a reliable way to handle formatting issues caused by conditional dynamic variables.