Some PHP page scripting skills related to WordPress SEO optimization _ php skills

Source: Internet
Author: User
This article mainly introduces some PHP page script skills related to WordPress SEO optimization, including distinguishing page titles and keywords. if you need them, you can refer to the following, A large amount of traffic is introduced to the websites that are listed above. whether it is the advertisement on the search page or the result, the matching degree with the target of the searcher is relatively high (if the search engine is intelligent enough ), therefore, visitors who use search engines may get what they want from the website and remember the website. that is to say, the search engine will bring a lot of valuable traffic, so it is worthwhile to spend some time optimizing the WordPress blog for the search engine. this article will share some WordPress SEO tips for you.

In the past, I didn't spend much time optimizing the search engine, and the search engine indexing effect was not very good. in last February, I finally engaged in SEO for my blog and wrote this article. over the past year and a half, more SEO optimizations have been carried out, blog articles have not been written much, traffic has increased, and websites have also returned to PageRank 7. The results are quite good. this time I updated the content of this article based on my WordPress SEO solution.

Optimize blog subtitles

Subtitle (slogan), which is called tagline in WordPress. it is different from the blog title. it may carry some words that describe the blog and can be used for optimization. for example, my subtitle is "mg12's Blog-Just Another WordPress Blog", where the WordPress Blog is set to h1because I want to tell crawlers that this is a Blog about WordPress.

Show different page titles

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 is not displayed ). the following code is used to output the title of a classic topic and a default topic.

<?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?>

The output title structure is "article title> blog name ".

Unless your title is highly relevant to the content of the article, such a title is obviously not good for SEO. the title is one of the content that crawlers think is important. if the title contains information unrelated to the content of the article, the page may be affected.

What should I do? We can differentiate different types of pages. my implementation code is as follows.

<? Php // if the homepage and article list page are displayed, the blog title if (is_front_page () | is_home () {bloginfo ('name') is displayed '); // if the document details page and independent page are displayed, the article title is displayed.} else if (is_single () | is_page () {wp_title (''); // if it is a category page, display the category description} else if (is_category () {printf ('% 1 $ s category object archive', single_cat_title ('', false); // if it is a search page, display the search expression} else if (is_search () {printf ('% 1 $ s search result', wp_specialchars ($ s, 1); // if the tag page is displayed, the label representation is displayed.} else if (is_tag () {printf ('% 1 $ s Tag Archive ', single_tag_title ('', false); // if it is a date page, display the date range description} else if (is_date ()) {$ title = ''; if (is_day () {$ title = get_the_time ('y, n, j, ');} else if (is_year ()) {$ title = get_the_time ('Y years ');} else {$ title = get_the_time ('Y years n month ');} printf ('% 1 $ s archive', $ title); // Other page displays blog title} else {bloginfo ('name') ;}?>

Keywords and Description

Keywords provides the search engine with the core content contained in the web page, and Description provides the web page Description information for the search engine. the theme I published once included the handling of keywords and description. However, due to some SEO plug-ins conflicts, it has been removed from newer versions. I believe that many of WordPress's so-called SEO plug-ins are not in place, and their support for Chinese blogs is poor. it may be better to modify them by yourself.

The following are my processing rules for keywords, description, and page titles. for the implementation method, refer to the previous section about the page title.

The description of the detailed page of the article generally takes the first 220 characters of the article, especially important pages and articles can be customized to make the information more accurate. if the abstract information exists, the abstract is used. If no abstract information exists, the first 220 characters are used. the implementation code is as follows.

<? Php if ($ post-> post_excerpt) {$ description = $ post-> post_excerpt;} the else {// utf8_trim method is used to escape strings before intercepting characters, avoid intercepting half of Chinese characters // Reference: http://php-utf8.61924.nl/documentation/functions/utf8_trim.html $ description = utf8_trim (substr (strip_tags ($ post-> post_content), 0,220);}?>

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.