WordPress 3.3 background function failure Solution

Source: Internet
Author: User
Tags php template set background

 

With the release of the official version of WordPress 3.3, many friends are upgrading their programs to the latest version immediately, but soon they will find some theme with the "background" feature (including the HotNews topic) the previously set background is invalid.

 

WordPress added the custom background body_class () function as early as 2.8, and the "background" function was not added to the default topic until 3.0. There are not many topics with this function, most topic designers may think that this function is a little tricky. It can be implemented simply by modifying the CSS style. There is no need to add a database query, but this body_class () function was originally intended, it is not to simply change the background of all pages on the entire site, but to facilitate the designer to flexibly control the various element styles on different pages. The principle is not mentioned. The specific solution is as follows:

 

Solution 1: WordPress 3.3 is in the program wp-des directory theme. add a custom-background tag in php, which causes the "background" function to fail. Enable theme. the php program file, which is found in row 1797th:

 

Body. custom-background {<? Php echo trim ($ style);?> }

 

Delete the. custom-background File:

 

Body {<? Php echo trim ($ style);?> }

 

This method is applicable to all topics that previously support the "background" function, but you need to modify the program file. I do not recommend this method.

 

Solution 2: This is a standard solution. Open the header. php template of the default theme Twenty Eleven and you will find the following:

 

<Body <? Php body_class () ;?>>

 

Instead of the normal <body> tag, this is the key. Replace the above Code with the <body> tag of the topic header. php template you use.

 

Solution 3

 

<Body class = "custom-background">

 

Replace the header. php template <body> tag without adding additional tags. This method is convenient and practical and suitable for all topics.

 

Next we will talk about the HotNews Pro 2.7Plus theme solution.

 

I. HotNews topic. After you modify the program file according to solution 1, the background function will be restored to normal without any changes.

 

2. Due to the complex feature structure of the HotNews topic, if you operate on solution 2, there are many template files to be modified, which may be troublesome. However, by tossing the topic, you may learn more, perform the following operations:

 

1. The HotNews Pro 2.7Plus topic has six header templates, which correspond to different page la S. Open all the template files starting with the header and replace all <body> labels in solution 2.

 

2. Search later:

 

Class = "home"

 

 

To:

 

Id = "home"

 

 

There are two reasons for modifying this tag:

 

<Body <? Php body_class () ;?>>

 

The ". home" tag is automatically generated on the homepage, which is in conflict with the topic style, resulting in the left of the homepage page.

 

3. Open all the style files in the styles directory of the HotNewspro topic and modify all the selectors starting with ". home" as "# home.

 

4. The simplest method is solution 3, which is used only:

 

<Body class = "custom-background">

 

Replace all the <body> tags starting with the header so that they do not automatically generate the ". home" tag, which is more convenient.

 

Tip: Modify the Chinese template to ensure that there is no BOM encoding format for the UTF-8, it is recommended to modify the background topic editing function or use Notepad ++ and other text editing software, remember not to use the notepad that comes with the system to edit the theme template.

Excerpted from zhiwubird

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.