About WordPress SEO optimization related to some PHP page scripting tips _php Tips

Source: Internet
Author: User
Tags wordpress blog

With the search engine Daxing, ranked in front of the site to introduce a lot of traffic. Whether the search page ads or the results of the search, and the target match of the searcher is relatively high (if the search engine is smart enough), so visitors from the search engine will likely get what he wants, and remember the site. That is to say, search engine will bring a lot of valuable traffic, so it is worthwhile to spend some time to optimize the WordPress blog for SEO. This article will share some WordPress SEO tips for you.

I didn't spend too much time doing search engine optimization, search engines are not very good results. Last February I finally made a SEO for the blog, write down this article. 1.5 has been more SEO optimization, blog articles are not written more, the flow is increasing, the site is also back to PageRank 7, the effect is quite good. This time I update the content of this article according to my own WordPress SEO scheme.

Optimize blog Subtitle

Subtitle (slogan), which is called tagline in WordPress. It is not the same as the blog title, may carry some description of the blog text, optimization can be used up. If my subtitle is "Mg12 's blog-just Another wordpress blog", which WordPress blog was I set to H1. Because I want to tell the crawler, this is a blog about WordPress.

Differentiate between display page titles

The title of the page does not include the blog name. WordPress headings typically use Bloginfo (' name ') and Wp_title (), which is the blog name and the article title (not shown if the title does not exist). The code for the classic theme and the default theme output header is as follows.

<title><?php wp_title (' «', True, ' right ');?> <?php bloginfo (' name ');?></title>

The title structure of the output is "article title» Blog name."

Unless your title and the content of the article is relatively high, otherwise such a title for SEO is obviously bad. The title is one of the things that reptiles think is important, if the title contains information unrelated to the content of the article, how much will affect the page.

How should we do that? We can differentiate between different types of pages, and my implementation code is as follows.

<title><?php
 //If is the homepage and the article List page, displays the blog title
 if (is_front_page () | | is_home ()) { 
 bloginfo (' name ');
 
 If it is an article detail page and a standalone page, display the article title
 } else if (Is_single () | | is_page ()) {
 wp_title (");
 
 If it is a class head page, display the class
 object expression} else if (Is_category ()) {
 printf ('%1 $ S Class Purpose article archive ', Single_cat_title (', false '));
 
 If it is a search page, display the search expression
 } else if (Is_search ()) {
 printf ('%1 $ s search results ', wp_specialchars ($s, 1));
 
 If it is a label page, display the label expression
 } else if (Is_tag ()) {
 printf ('%1 $ s Tagged article archive ', Single_tag_title (', false '));
 
 If it is a date page, display a date range description
 } else if (Is_date ()) {
 $title = ';
 if (Is_day ()) {
  $title = get_the_time (' Y year n Month J Day ');
 } else if (Is_year ()) {
  $title = get_the_time (' y year ');
 } else {
  $title = get_the_time (' Y year n months ');
 }
 printf ('%1 $ S Article archive ', $title);
 
 Other pages show blog title
 } else {
 bloginfo (' name ');
 }
? ></title>

Keywords and Description

Keywords provides the search engine with the core content of the Web page, and Description provides the Web page with descriptive information. The topics I published once included handling of keywords and description, but since some SEO plug-ins have clashed, they have been removed in newer versions. The author thinks that many of WordPress's so-called SEO plug-ins do not in place, the support of Chinese blog is very poor, you can modify the effect may be better.

Here are my rules for keywords, description, and page headers, and the implementation method can refer to the description of the page title in the previous paragraph.

Article detailed page description generally take the first 220 characters of the article, especially important pages and articles can be customized summary, so that its information accuracy higher. If there is summary information, use the summary, the first 220 characters are not used, the implementation code is as follows.

<?php
 if ($post->post_excerpt) {
 $description = $post->post_excerpt;
 } else {
 //Utf8_trim The method is to escape the string before intercepting the character, avoiding the case where half Chinese characters are intercepted
 //reference documents: http://php-utf8.61924.nl/documentation/functions/utf8_trim.html
 $description = Utf8_trim (substr (Strip_tags ($post->post_content), 0));
>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.