


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)); } ?>

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。


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

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version
