= 2 || $page>=2)" statement; finally change the statement after if to "sprintf(__ ('Page %s')" will do."/> = 2 || $page>=2)" statement; finally change the statement after if to "sprintf(__ ('Page %s')" will do.">

Home  >  Article  >  CMS Tutorial  >  How to add page number to blog title in WordPress

How to add page number to blog title in WordPress

angryTom
angryTomOriginal
2019-11-16 11:24:072530browse

How to add page number to blog title in WordPress

How to add page number to blog title in WordPress

Many friends will optimize the website to prevent duplicate content. Add page numbers when paginating articles or lists to prevent duplicate titles from appearing. Let’s introduce to you how to add page numbers to the blog title in WordPress.

1. Open header.php. This is before modification. The code is as follows:

if ( $paged >= 2 || $page >= 2 ) 
    echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );

2. The modified code is as follows:

if ( $paged >= 2 || $page >= 2 ) 
    echo ' | ' . sprintf( __( '第 %s 页', 'twentyten' ), max( $paged, $page ) );

3. Everyone's theme may be different. In fact, you only need to change 'Page %s' to 'Page %s'. If you don't know how to program, we can Add the following code to the template page:

<?php
$paged = get_query_var(&#39;paged&#39;);
if ( $paged > 1 )
    printf(&#39; – 第 %s 页 &#39;,$paged);
?>

Recommended tutorial: WordPress Tutorial

The above is the detailed content of How to add page number to blog title in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn