Modify topic author and other information wordpress

Source: Internet
Author: User

The default WordPress style sheet must follow the topic name in the first line and the topic address in the second line. If it is used to publish a paid topic. The third line is the topic description, the fourth line is the version number, and the fifth and sixth lines are the topic author's name and homepage respectively.

Get_theme_data ()

This example returns the topic information in the style.css file in the topic file, that is, the topic description format that each wordpress topic style page header must comply, the parameter must be specified as your topic file name.

The following lists the theme information that can be returned by the function:

  • Topic URI

  • Description-Topic description in wordpress format

  • AuthorURI-URI of the topic author

  • Template-The main Template Name of the topic is optional in wordpress)

  • Version-Topic version

  • Status-Topic status (default value: publish)

  • Tags-Topic tag

  • Author-Subject author name

For example, write in style.css:

/*
ThemeName: brokensky
ThemeURI: http://www.brokenjoin.org
Description: It 'sathemecreatebybrokenjoin
Version: 1.0
Author: guolizhou
AuthorURI: join
Tags: customheader, fixedwidth, twocolumns, widgets
*/


Note that the parameter names of these return valuesUppercase letters are required.Otherwise, no correct value is returned.

It is the most direct and simple method. To obtain other information, you only need to replace the content in square brackets.

$ Theme_name = 'twentyeleven ';
$ Theme_data = get_theme_data (get_theme_root (). '/'. $ theme_name. '/style.css ');
Echo $ theme_data ['title'];
Echo $ theme_data ['author'];

Instance usage instructions

Topic developers have version tracking for their own developed themes, or you are a user of a paid topic. After the author upgrades, you do not know the current topic version, the following function will give you a clear picture of the current version.

// Obtain and display the topic version number
Functiontheme_version (){
$ Theme_name = 'twentyeleven'; // name of the topic you are using
$ Theme_data = get_theme_data (get_theme_root (). '/'. $ theme_name. '/style.css ');
Echo '? V = '. $ theme_data ['version'];
}

The page front-end call code and final HTML output are as follows:



Of course, we can also change our theme_version () function to short code for convenient use through some appropriate modifications.

// Short code function of Version Number
Functiontheme_version_shortcode (){
$ Theme_name = 'xycss '; // customizewithyourthemename
$ Theme_data = get_theme_data (get_theme_root (). '/'. $ theme_name. '/style.css ');
Return $ theme_data ['version'];
}

The short code is called as follows:

[Theme_version]

The output html result is:

1.3


The above example is just the simplest use of the get_theme_data () function.



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.