


Some PHP page script skills related to WordPress SEO optimization_php skills
With the rise of search engines, top-ranked websites attract a large amount of traffic. Whether it is the advertisement on the search page or the results found, the matching degree with the searcher's goal is relatively high (if the search engine is smart enough), so through Visitors coming from search engines are likely to get what they want from the website and remember the website. In other words, search engines will bring a lot of valuable traffic, so take the time to optimize WordPress for search engines. Blogging is also worthwhile. This article will share some WordPress SEO tips for you.
I didn’t spend much time doing search engine optimization before, and the search engine indexing effect was not very good. In February last year, I finally did some SEO for the blog and wrote this article. In the past year and a half, I have done more SEO. Optimization, I haven’t written many blog posts, but the traffic has increased, and the website has returned to PageRank 7, which is quite good. This time I updated the content of this article based on my own WordPress SEO plan.
Optimize blog subtitle
Subtitle (slogan), called tagline in WordPress. It is different from the blog title. It may carry some text describing the blog, which can be used after optimization. For example, my subtitle is "mg12's Blog - Just Another WordPress Blog" , the WordPress Blog is set to h1 by me. Because I want to tell the crawler that this is a blog about WordPress.
Distinguish the page title
Do not include the blog name in the page title. WordPress titles generally use bloginfo('name') and wp_title(). The former is the blog name, and the latter is the article title (if the title does not exist, it will not be displayed). The code used to output the title of the classic theme and default theme is as follows.
<title><?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?></title>
The output title structure is "Article title » Blog name".
Unless your title is highly relevant to the article content, such a title is obviously not good for SEO. The title is one of the contents that crawlers consider important. If the title contains information that is irrelevant to the article content, how much This page will be affected.
So how should we do it? We can distinguish different types of pages. My implementation code is as follows.
<title><?php // 如果是首页和文章列表页面, 显示博客标题 if(is_front_page() || is_home()) { bloginfo('name'); // 如果是文章详细页面和独立页面, 显示文章标题 } else if(is_single() || is_page()) { wp_title(''); // 如果是类目页面, 显示类目表述 } else if(is_category()) { printf('%1$s 类目的文章存档', single_cat_title('', false)); // 如果是搜索页面, 显示搜索表述 } else if(is_search()) { printf('%1$s 的搜索结果', wp_specialchars($s, 1)); // 如果是标签页面, 显示标签表述 } else if(is_tag()) { printf('%1$s 标签的文章存档', single_tag_title('', false)); // 如果是日期页面, 显示日期范围描述 } else if(is_date()) { $title = ''; if(is_day()) { $title = get_the_time('Y年n月j日'); } else if(is_year()) { $title = get_the_time('Y年'); } else { $title = get_the_time('Y年n月'); } printf('%1$s的文章存档', $title); // 其他页面显示博客标题 } else { bloginfo('name'); } ?></title>
Keywords and Description
Keywords provides search engines with the core content of web pages, and Description provides search engines with description information of web pages. The theme I published once included the processing of keywords and description, but due to conflicts with some SEO plug-ins, in newer has been removed from the version. The author believes that many so-called SEO plug-ins in WordPress are not done well and have poor support for Chinese blogs. It may be better to modify them yourself.
The following are my rules for processing keywords, description and page titles. For implementation methods, please refer to the description of page titles in the previous paragraph.
The description of the article detailed page generally takes the first 220 characters of the article. For particularly important pages and articles, you can customize the summary to make the information more accurate. If summary information exists, use the summary, if not, use the previous 220 characters, the implementation code is as follows.
<?php if($post->post_excerpt) { $description = $post->post_excerpt; } else { // utf8_trim 方法是为了在截取字符之前对字符串进行转义, 避免出现截取半个汉字的情况 // 参考文档: http://php-utf8.61924.nl/documentation/functions/utf8_trim.html $description = utf8_trim(substr(strip_tags($post->post_content), 0, 220)); } ?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Wordpress site file access is restricted: troubleshooting the reason why .txt file cannot be accessed recently. Some users encountered a problem when configuring the mini program business domain name: �...
