WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Requires Small Fix for Title Page Numbering (4 posts)

  1. a1wsn
    Member
    Posted 3 years ago #

    Currently %%pagenumber%% and %%pagetotal%% display nothing if there is only 1 page. That makes a pretty ugly title if you're using something like (page %%pagenumber%% of %%pagetotal%%) for your archives or categories, resulting in (page of )

    Please make these tags display 1 if there is only 1 page.

    Thanks!

  2. a1wsn
    Member
    Posted 3 years ago #

    I see Joost has released many good bugfixes since release, but not this one. Please Joost, this bug makes bad titles!

  3. a1wsn
    Member
    Posted 3 years ago #

    OK, here is a quick fix in case anyone is interested (I know at least one other person has reported the same problem).

    First find this code, probably in your header.php :

    <title><? wp_title(''); ?></title>

    REPLACE that code with the following :

    <? ob_start(); ?><title><? wp_title(''); ?></title><? $wp_headttl = ob_get_contents(); ob_end_clean(); $wp_headttl = str_replace('page of', 'page 1 of 1', $wp_headttl); echo $wp_headttl; ?>

    This gets the title output by Yoast's plugin, puts it into a string, then replaces the empty page numbering section, and then finally prints the resulting fixed title.

    Note that you may need to adjust the code slightly depending on how you setup your title templates, for example if the word 'page' is capitalized in your titles then you'll need to change 'page of' to 'Page of'. So basically you should just look at your current broken title and copy the bit you want removed into the first single-quoted section of the str_replace in the code above.

    I hope this helps someone! If you are code-challenged and can't figure it out then you can post a link to your site here and I'll reply with the exact code to fix your page numbering problem :)

  4. maxyRO
    Member
    Posted 2 years ago #

    Hey

    I tried your solution but nothing happens. Does it currently work for you? My blog is this

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic