Support » Plugin: Yoast SEO » [Plugin: WordPress SEO by Yoast] Requires Small Fix for Title Page Numbering

  • 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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter a1wsn

    (@a1wsn)

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

    Thread Starter a1wsn

    (@a1wsn)

    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 🙂

    Hey

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] Requires Small Fix for Title Page Numbering’ is closed to new replies.