Home > CMS Tutorial > WordPress > body text

How to add page number to blog title in WordPress

angryTom
Release: 2019-11-16 11:24:07
Original
2590 people have browsed it

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 ) );
Copy after login

2. The modified code is as follows:

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

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);
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template