To all the wordpress novice, how to detect download the wordpress theme plugin contains the back door

Recently a lot of small partners have been discussing the site was black and download the free wordpress theme plugin hanging horse topic, then today V to teach you how to identify the wordpress theme plug is left behind the door. First of all, under the wordpress operating environment, I believe that a little bit of common sense of the owners know that wordpress is a run on the php + mysql system built on top of the system, and wordpress theme plug-ins are written as. Php suffix executable file this Is why wordpress’s free theme plugin is easy to stay behind the door problem. Since it is written by php, then we just know that the general use of PHP backdoor procedures can be a certain degree of awareness of the theme plug-in whether there is a backdoor Trojans, the following small V lists some common php backdoor function:
Execute system commands: system, passthru, shell_exec, exec, popen, proc_open (high risk)
Code execution: eval, assert, preg_replace (‘/ $ pattern / e’) (high risk)
File operations: file_get_contents, file_put_contents, fputs, fwrite (high-risk)
String encryption and decryption compression decompression hidden: base64_decode, gzinflate, gzuncompress, gzdecode, str_rot13, base64_decode, gzcompress, chr (suspicious)
wordpress Create backdoor user: wp_create_user, WP_User, set_role (high risk)
If the subject of small V mark the high-risk code can basically determine this theme is very problematic, and basically are to stay back door or do little tricks. If it is found in this article marked suspicious code that should be noted that the code is likely to encrypt the part of the back door. Many small partners certainly do not understand preg_replace (‘/ $ pattern / e’) What is the meaning of this code, the following small V to explain to you, preg_replace function using e modifier after the implementation of the reverse reference replacement will be replaced Of the code as php code to run, so it is also a very common backdoor code. In the detection of the theme plug contains the back door as long as the text search tool or software search theme plug-in php file contains the above keywords, in the search for preg_replace need to manually compare the code to see whether the inclusion of e modifier, if the subject file (5) .chr (3) .chr (58) This kind of code should be careful, and found that the subject file appears a lot of random characters have to be careful are generally encrypted code is likely to hide The back door.
PS: Because the usual beard finishing the theme and plug-ins are more, it is difficult to check all the documents are submitted side. Up to check the next few key files are hanging horse, so please download the theme as much as possible after their own check again.

Inspira Agency remains at the forefront of industry innovation, and are constantly revising our service offerings to ensure all your online marketing needs are covered because our goal is to provide you with SEO solutions for all of your online needs Website Development in Bangkok Inspira offers responsive and modern web design to small and medium businesses as well as larger organizations. Inspira Agency also offers SEO services to make sure your website get the visibility it deserves.

WordPress change the domain name to pay attention to ten things

WordPress replacement domain name may have been experienced in the old and new domain name replacement process, how to make the loss to a minimum, which focus on SEO owners who is essential. One side of my own experience to talk about WordPress change domain name after the attention of ten things.
First, modify the database configuration file
If you change the domain name on the same host in the same space, this step can be saved. If the database is different, you have to open wp-config.php to properly configure the database to access the new domain.
Second, change the blog’s installation address and blog address
First use phpmyadmin to open your database, and then find the wp-options this data table, find the first record is siteurl this, there are 39 home, the two will be changed to your replacement after the domain name can be The Only to complete this step, you can successfully enter the background, or even if you enter the password, it will automatically jump to the original old domain name.
Third, modify the article all the links within the new domain name
I believe we published in the previous article must be added a lot of the chain, the domain name replaced, the old chain also no meaning. In this case, you should change the old domain name in the article to the new domain name. If the background from the editor of a search that is unrealistic, there is a way, universal phpmyadmin into your database, the implementation of the following statement can be all within the article within the chain of old domain name to the new domain name:
UPDATE wp_posts SET post_content = replace (post_content, ‘http://www.xiaohu520.com’, ‘http://www.ztmao.com’);
Four, to re-visit the search engine site
Because the replacement domain name, all from scratch, so if the search engine to re-submit a new domain name, submitted to the process, we must pay attention to my article mentioned several points of attention. After the submission, it is a long waiting process, do not worry, because the start again, that this waiting process, you only put the energy on the original article.
Fifth, the old domain name 301 redirect to the new domain name
Do not think of the old and new domain names are pointing to the same station, this will cause “domain name bombing.” The result of this will not only give your website more traffic, but the search engine that your cheating, down your weight is small, it is not impossible for your station K is not possible. If you want to retain the old domain name of the users, it would have to make a 301 redirect. 301 redirect to SEO or friendly, there are many specific methods, the specific operation is not in this one one detailed
Six, re-modify the statistical code
This should be a very simple thing, and then to the statistical site to apply for the new domain name statistics, the old domain name statistics can be covered.
7. Re-change the feed subscription address
RSS feed subscription is to maintain a station traffic is an important factor, when your domain name are replaced, how others also subscribe. So you should re-set the subscription address, and try to notify the old domain name has been changed friends. Also modify the RSS feed subscription address at the appropriate location on the home page.
8, inform your friendship link
Before your 301 redirect is still in effect, be sure to inform your link and change the old domain name to the new domain name. If 301 is invalid and your link has not been notified, then your link will be meaningless.
9, check the plug-in is working properly
Although the plug-in settings are part of the domain name has nothing to do, but we all know WordPress function is to rely on plug-ins, so replace the domain name, it is best to check whether a plug-in is working properly. Such as Baidu Sitemap Generator and Google XML Sitemaps two plug-ins, must be disabled and then enabled to work properly.
Ten, to your frequent visits to the blog message for rice
I have dozens of visits, basically every day to see, in the bloggers to comment on the time casually talk about your blog for the domain name. Played a hundredfold multiplication effect.

WordPress 4.0.1 fixes 8 security risks and 23 bugs

WordPress 4.0.1 is now available. This is a critical update for the previous version, and it is strongly recommended to update your site immediately.
Web sites that support automatic background updates will automatically be updated to WordPress 4.0.1 over the next few hours. If you are still using WordPress 3.9.2, 3.8.4 or 3.7.4, you will be updated to 3.9.3, 3.8.5, 3.7.5. (We do not support the old version, so please update to the latest best 4.0.1)
WordPress version 3.9.2 and earlier are subject to a critical cross-site scripting vulnerability that could allow anonymous users to compromise the site. This issue does not affect the 4.0 version, but the 4.0.1 version solves the following eight security issues:
3 cross-site scripting problems that can be used by the contributor or author to destroy the site
A cross-site request forged can be used to trick users into changing passwords
1 question that may result in a denial of service when checking the password
When WordPress sends an HTTP request, additional server-side requests for an attack
A very unlikely hash conflict could have affected the user’s account, which also requires them to have not logged in since 2008 (I wish I was kidding)
WordPress now password reset the link in the message, if the user remembers their password, log in, can modify their email address.
4.0.1 also fixed 4.0 of the 23 bug, and we also made two hardening changes, including a better validation of the excerpt from the upload photos of EXIF ​​data.

WordPress add color tag cloud

Tag cloud is a lot of WordPress theme has a theme element, today about how to add color for your theme tag cloud, including the sidebar call and page calls.

1. Call the tag cloud
We can use the wp_tag_cloud () function to implement the tag cloud call. For example, the following example:

  1. <?php wp_tag_cloud(‘smallest=12&largest=18&unit=px&number=0&orderby=count&order=DESC’);?>

Code Comments:
smallest represents the smallest size of the label
largest represents the largest font size
unit = px indicates that the font uses pixel units
number = 0 means that all labels are displayed, and if it is 40, it means 40
orderby = count means the number of articles associated with the label
order = DESC for descending order (ASC for ascending order, DESC for descending order)
For more information on wp_tag_cloud (), please refer to the WordPress documentation wp tag cloud

2. Add a color function
According to the above parameters, you can already call out the tag cloud and add the following code to the last one of the theme’s functions.php?> In front of the color:

  1. //边栏彩色标签
  2. function colorCloud($text) {
  3.     $text = preg_replace_callback(‘|<a (.+?)>|i’,’colorCloudCallback’, $text);
  4.     return $text;
  5. }
  6. function colorCloudCallback($matches) {
  7.     $text = $matches[1];
  8.     $color = dechex(rand(0,16777215));
  9.     $pattern = ‘/style=(‘|”)(.*)(‘|”)/i’;
  10.     $text = preg_replace($pattern“style=”color:#{$color};$2;””$text);
  11.     return “<a $text>”;
  12. }
  13. add_filter(‘wp_tag_cloud’, ‘colorCloud’, 1);

3. Make the tag cloud page
You can take a look at the theme cat tag cloud page:
1) Copy your theme page.php file at the top of the file Add:

  1. <?php
  2. /*
  3. Template Name: Tags
  4. */
  5. ?>

2) Replace the page.php with the following code:

  1. <?php wp_tag_cloud(‘smallest=12&largest=18&unit=px&number=0&orderby=count&order=DESC’);?>

3) The page generally does not require comment function, remove the following code in page.php:

  1. <?php if (comments_open()) comments_template( , true ); ?>

4) You can also according to their own needs, delete some of the functions in page.php, and finally save the file as page-tags.php, so that a tag cloud template to do a good job.
5) visit the WP background – page – create a new page, the page name to fill their own, just in the page properties, select the tags template can:

4. Call the tag cloud in the sidebar
You can use the following function call, the specific method of modification, on your own toss the theme:

  1. <?php wp_tag_cloud(‘smallest=12&largest=18&unit=px&number=20’);?>

However, the general production of more standardized WordPress theme, support Widget gadget, you can in the WP background – appearance – gadget to see whether to support the tag cloud gadget.
Note: This article just tells you how to implement the color tag cloud and how to call it. But the specific style, it is necessary to rely on your own through the CSS code to achieve.

WordPress template architecture

header.php (website head)
This is a global file (easy IT Note: WordPress generated each page will contain the header.php code), display the page header (header) and navigation menu, also contains the HTML file head code (<head> … </ head>). </ p>
The loop (the page body)
The main content of the site is displayed in the main area of ​​the site through a template file containing the “loop” structure.
sidebar.php (sidebar)
This file controls what sidebar shows. If there are multiple sidebars, you can set in the functions.php file, the sidebar “widgets” content can be set in WordPress management control panel (wp-admin).
footer.php (bottom)
The code that contains the global bottom file and closes the HTML tag (</ html>).
The WordPress theme is made up of a series of files in the template folder (.. / wp-contents / themes / template name /), each of which controls the different parts of the template. No matter which page on the site, some parts of these pages are generally static, controlled by the header, siderbar, and footer files. You can modify these files to see which parts of the site are controlled by which files.
Home page
index.php
index.php is used to control how the home page of the site is displayed. The index.php defaults to a query and displays the loop of the latest article and displays a hyperlink at the bottom to view the previous article.
Alternatively, you can set any page you created in wordpress as the home page in wp-admin> settings> read. In other words, you can set a different page (or url) as a regular blog article as a home page to display, and that page or through the index.php template generated.
Posts (posts)
single.php
single.php is used to control how the article page is displayed. This file contains queries and displays the current article loop.
If you want to display the sidebar (and other elements you want to display), you can specify it in this file. You can also modify the file to make the article page and other pages are different.
Pages (pages)
page.php
page.php controls the display of WordPress Page (page, different and post). You can choose to remove the sidebar or other elements, or add some elements only the page.
WordPress also allows you to create different page templates that are used to display different types of pages. Create a page template is very simple, you just copy page.php, change your favorite name, and then add the following code at the top of the file:
<? php
/ *
Template Name: The name of the page template file you named
/ *
?>
Archives
archive.php, category.php, tag.php
You can use the above files to control the display of various archive class pages. If the archive page template is not archived, the archive page will use index.php as a template; however, you can create an archive.php instead of index.php as the template for the archive class page. If you created category.php, this file will replace archives.php as a template for the categories. If you created tag.php, this file will be preferred as a template for the tag page.
The Loop
The loop may be the most powerful part of the wordpress template. It starts from a query (to decide which article or page data to grab) and has an end loop. The loop shows what depends on your needs. You can display the title of the article in the loop, the content of the article, the metadata (author, date, etc.), custom fields and comments, etc. These elements are the output of an article or page. You can also create multiple queries and loops on an article or page; for example, in single.php, you can create a loop to display the contents of a single article and then use another loop to display under the article content The title and thumbnail of the article related to this article.
Article and page query mechanism
Start the cycle
(Repeat this and endwhile between all the contents until all the relevant content of the article are finished)
the_title
(Output the title of the article)
the_excerpt
(The introduction of the article)
the_content
(The main content of the output article)
the_category
(The name of the output article)
the_author
(The author of the output article)
the_date
(The date of the output article)
other tags
(Can be inserted in the cycle of the various templates used in the label)
Endwhile
(Repeated until all queries have been output)
Behind the scenes of other mechanisms
To make the wordpress theme template work, you also need some important files in the background. You can modify these files according to their own needs, to customize the function of the site and how to display.
comments.php
This file controls how the comments are displayed, and the file contains a loop that queries all the comments for an article. comments.php can be overridden by some plugins, such as Disques, that these plugins can take over the comments of the site.
functions.php
functions.php allows you to add your own php code to modify the core elements of the wordpress theme. Usually this can be used to add multiple sidebars to their own theme, modify the number of characters in the article (excerpt), or add your own admin panel options to wp-admin.
style.css
This is the main template style file for the theme template. At the same time at the top of the file, contains the subject name, the author and your site URL and other related text, so WordPress to know the subject of this information.
other
In addition to the core features of WordPress, other similar plugins, custom fields and wedgets allow you to customize your website further.
Plugins
There are a lot of open source developer community developed a lot of plug-ins, you can add them to your website for free, including e-commerce, slideshow (slideshow), cache and social function.
Custom Fields
The custom field is when you create an article and can be entered in the input box below the article content input box. Through the custom domain, you can create your own options or content, and then you can use them in the theme template or display them. It is often used with thumbnails and used to include javascript code (include).
Widgets
The gadget is a small module for the sidebars. In wp-admin, you can configure the default gadget, you can also add a variety of plug-ins provided by the gadget, or php code. Gadgets typically include content such as search forms, popular article lists, and ad blocks.

WordPress do not use plugin with ajax refresh sidebar random article

A friend sent me to ask me, my sidebar that refresh the effect is how to achieve. Can share
In fact, I intend to share these days, that is, time is not allowed, and now we share under how to use ajax refresh wordpress sidebar random article bars
DEMO
Click on the blog sidebar “refresh” you can see.
How to achieve?
First make sure your theme is called in the js library, and the following code can be found in the topic file header.php. If you do not have it, please copy and paste it before the label.
<script type = “text / javascript” src = “http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js”> </ script>
1, to determine the scope of the article code id. The blog’s random article html code is roughly as shown below. You can also find similar code in your website template. Each topic calls the same function, the middle of a string of code can be ignored.
<h2 class = “sub”> recommended reading </ h2>
<div id = “postlist1”>
<ul class = “spy”>
<? php $ my_query = new WP_Query (‘orderby = rand & showposts = 5’);?>
<? php while ($ my_query-> have_posts ()): $ my_query-> the_post ();?>
<li> <? php $ screen = get_post_meta ($ post-> ID, ‘screen’, $ single = true);?>
<h2 style = “overflow: hidden;”> <a href=”<?php the_permalink()>> “title =” <? php the_title ();?> “> <? php the_title ();?> < a> </ h2>
</ li>
? php endwhile;?>
</ ul>
</ div>
<a href=”#” id=”another”> refresh </a>
Among them, you also need to add a “refresh” to your immediately article code. That is the following code.
<a href=”#” id=”another”> refresh </a>
Also note that the ID “frontlist1” and the last parcel “refresh” ID “another” in front of the ul tag will be used.
2. Create a page template named Random Post. PS: Do not copy the following code. Where the article call function is copied directly from the sidebar.php in the currently used theme.
<? php
/ *
Template Name: Random Post
* /
?>
<? php $ my_query = new WP_Query (‘orderby = rand & showposts = 5’);?>
<? php while ($ my_query-> have_posts ()): $ my_query-> the_post ();?>
<li> <? php $ screen = get_post_meta ($ post-> ID, ‘screen’, $ single = true);?>
<h2 style = “overflow: hidden;”> <a href=”<?php the_permalink()>> “title =” <? php the_title ();?> “> <? php the_title ();?> < a> </ h2>
</ li>
<? php endwhile;?>
3, create a page using the above template, and publish.
We can click here to view this page of this site / random
4, jQuery
Copy and paste the following code into your subject header.php file before placing it on the label.
Where # polist1 and #another are found in step one, combined with your own theme changes.
<script type = “text / javascript” charset = “utf-8”>
$ (). ready (function () {
$ (“# postlist1”). load (“/ random /? offset =” + offset);
$ (“# another”). click (function () {
offset = offset + 5;
$ (“# postlist1”)
.slideUp ()
.load (“/ random /? offset =” + offset, function () {
$ (this) .slideDown ();
});
});
</ script>
5 until all ends, you’re done!

WordPress Integrated Alipay

How to integrate in the WordPress program Alipay is to achieve WordPress e-commerce must break through a bottleneck. WordPress has a lot of e-commerce class plugins, like the more famous WP e-Commerce and so on. But the only drawback of these plug-ins is not enough localized, do not support Alipay. Perhaps because WordPress Alipay integrated business application value is relatively high, few people are willing to share the relevant experience free of charge. There are generally WP master are relatively low-key, busy to make money to go. In the online collection of relevant information I have nothing, in addition to that was reprinted hundreds of times I do not know who wrote the so-called tutorial. Here is not to link, because it is not clear who is already original. First explain: This operation requires you to be familiar with the wordpress template and understand the WordPress custom domain related knowledge, understand a little HTML and CSS. Nonsense does not say, the following is a detailed step.
1, first of all if you want to pay a business contract, and apply for a secured transaction or immediately to the transaction, (I apply for immediate arrival) to apply for a general audit period, but Alipay staff efficiency is still very high.
2, after the application you will get an Alipay security check code (key) and a partner identity (Partner ID). This is the official help (graphic). These two numbers are very important, the following will be used.
3, landing Alipay account business service page download integrated technical documents. Or you can go to Alipay Forum download. (Note: download php + utf8).
4, followed by the parameter configuration, you only need to modify the alipay_config.php this file can be.
// partner ID, 16-bit pure number beginning with 2088
$ partner = “”;
// security check code, 32-bit characters consisting of numbers and letters
$ key = “”;
/ / Signed Alipay account or seller Alipay account
$ seller_email = “”;
/ / Transaction process server to notify the page to use http: // format full path, not allowed to add id = 123 such custom parameters
$ notify_url = “http: //www.yourdomain/alipay/notify_url.php”;
/ / Pay the page after the trip to use http: // format full path, not allowed to add id = 123 such a custom parameter
$ return_url = “http: //www.yourdomain/alipay/return_url.php”;
/ / Site products display address, not allowed to add id = 123 such a custom parameter
$ show_url = “”;
// Name of recipient, eg company name, website name, payee name, etc.
$ mainname = “”;
5, will modify the file upload to your site’s root directory, be careful not to change the original directory structure and file name. Quick payment entry template file (index.php), picture, CSS style folder (images) without upload. These two files can be integrated into your wordpress theme. For example I was at http://www.mydomain.com / alipay
6, in fact, where the Long March has been the first step, and then the treasure will be integrated into your theme in the desired location. Such as a single article page (single.php). Integration of the overall idea is to use WordPress custom domain, the value through the form hidden domain or URL parameters with POST way to pass to the interface, and assigned to the interface form to achieve. Here are three very important parameters: product name, description of goods and commodity prices.
Note: form a name is to pay the official file provided by the official treasure naming, generally do not change. If you have a high level of exception.
7, the following is a specific example of code, I integrated it into a single log file. Of course, your WP theme is best designed to change the door of the product page template, rather than the article page common to a template.
<div class = “alipay”>
<FORM name = alipayment action = / wordpress / alipay / alipayto.php method = post target = “_ blank”>
<INPUT type = “hidden” size = 30 name = aliorder value = “<? Php echo get_post_meta ($ post-> ID,” P_name “, true);?>” Maxlength = “200”
<INPUT type = “hidden” maxLength = 10 size = 30 name = alimoney value = “<? Php echo get_post_meta ($ post-> ID,” P_price “, true);?>”
<input type = “hidden” name = alibody value = “<? php echo get_post_meta ($ post-> ID,” P_description “, true);?>”>
<input type = “hidden” name = “pay_bank” value = “directPay”>
<input type = “submit” class = “btn” value = “buy” />
</ FORM>
</ div>
8, here in fact Alipay function has been used. Add a new article, add the appropriate custom field, and then publish. See if you can buy online already? The next step is to beautify the work, if you are proficient in CSS, proficient in HTML form design, proficient in JQURY, you can make payment more beautiful and more secure.
9, if you still have the energy, you can consider the integration of Alipay into plug-ins, improve the relevant configuration options to achieve WordPress background order query and tracking. This is achievable, WordPress has the potential to create a more than ECSHOP or SHOPEX also want to play online shop, and in the search engine optimization performance will be better than the latter two.

WordPress Recycle Bin feature configuration

WordPress Recycle Bin is a feature introduced by WordPress 2.9.
Starting with WordPress 2.9, we can put any content, comments, attachments into the WordPress Recycle Bin. Into the Recycle Bin, we can restore the contents of the Recycle Bin, you can also completely delete the contents of the Recycle Bin.
On the WordPress Recycle Bin function, in addition to the above description, you need to know the following.
First, customize the WordPress Recycle Bin to delete the time
WordPress Recycle Bin content, the default will be deleted after 30 days, the logic is very simple, otherwise the WordPress Recycle Bin will be more bloated.
Of course, if you think 30 days is too long, we can also customize the content storage time, we need to add the following code to wp-config.php Lane.
define (‘EMPTY_TRASH_DAYS’, num);
num = days. By default, here should be the number of days, according to their own hobbies, set the corresponding number of days. After this expires, the content is automatically deleted.
Second, the WordPress Recycle Bin set to delete function.
But that does not mean that we have to always use this recycle bin function, just like some friends know this feature after the evaluation, WordPress official is more and more “out of business”.
Some people still like to immediately delete the content, do not want to operate again in the Recycle Bin, the implementation method is very simple, just need to:
define (‘EMPTY_TRASH_DAYS’, num);
In the num into 0 can be, then moved to the Recycle Bin will become permanently deleted, will not be put into the Recycle Bin, delete directly.

WordPress access slow solution

First, disable Google resources
WordPress many themes using Google’s services, and now Google is a large-scale shielding, a serious impact on the site’s visit speed, so banned! There are two ways to do this, one using plugins: Disable Google Fonts (or other Google Fonts plugins); another way is to add code directly in functions.php:
/ **
* remove google fonts
* by: www.jiawin.com
* /
function remove_open_sans () {
wp_deregister_style (‘open-sans’);
wp_register_style (‘open-sans’, false);
wp_enqueue_style (‘open-sans’, ”);
}
add_action (‘init’, ‘remove_open_sans’);

Second, modify the Gravater head to the wall
2014 Gravatar server wall, leading to the head are not shown, causing the site speed was slowed down. You can use the following code to solve the problem by the wall, of course, you can also use the Gravatar header cache approach to speed up.
/ **
* en.gravatar.com
* by: www.jiawin.com
* /
function quickly_gravatar ($ avatar) {
$ avatar = str_replace (‘? s =’, ‘.png? s =’, $ avatar);
$ avatar = preg_replace (“/ ([0-9]).. gravatar / i”, “en.gravatar”, $ avatar);
return $ avatar;
}
add_filter (‘get_avatar’, ‘quickly_gravatar’);

Third, delete the extra plugin
One of the strengths of wordpress is that it’s easy to scale, and there are a lot of great plug-ins that can meet all your needs, but for that reason, most of us have installed a lot of plug-ins, which affect the site’s Access speed. So here, it is recommended that you ban the extra plug-ins, only for their own plug-in is the best. So how do you start deleting the extra plugin?
1, audit each plug-in to see if it is necessary, if not please delete
2, check the plug-in version, keep the latest version of the plug-in, if the plug-in update time is a few years ago, please delete it
3, plug-ins as far as possible in the wp official download, to avoid the impact of bad plug-ins

Fourth, optimize the picture resources
Each site will have picture resources, the picture is often loaded into a website inside the file one of the largest resources, so we must manage the picture. Picture format suggested that you use the commonly used format jpg, png and gift, save the picture, try to reduce the size of the compression, but can not affect the use. Can be optimized
1, use the height and width attributes, make up the alt attribute (for seo friendly)
2, the use of tools to optimize the picture
3, the use of reliable image storage services

Five, the subject of the code efficiency
Wordpress theme can be said to be all-inclusive online, there are free, there are paid, but also have their own production, a theme determines a site shell containers, if the container is not good, then we can not even good things. So we should be careful choice, not only need to have a good interface, but also requires a reliable, excellent code of the theme.
In some time ago, re-customized a new theme, which optimized the efficiency of the implementation of php code, the effect is still very good, compared to a blog theme, the size of the first page reduced by half, sql query also reduced by half, the pressure on the server Greatly reduced. Here mention the theme code efficiency, in fact, PHP code level optimization, you can start from the following aspects:
1, optimize the efficiency of PHP implementation
2, to reduce the number of sql inquiries
3, delete some of the functions to static
4, set the php cache

Six, the host server
This is an optimization of the server, for example, can be lightweight, high-performance Nginx, load balancing, etc., the specific program is not described in detail. Here to suggest that the website, the server must be good, spend money can buy you a lot of time, energy.

WordPress forget the background login password solution

After the installation of wordpress forget to record the default password or use the wordpress for some time after the forgotten password how to do? CMS concentration camps sorted out six kinds of wordpress forget the password solution, recommended to the owners.
1, reinstall WordPress. We do not recommend this method, reinstall the installation file to download more trouble.
2, use the password recovery function. WordPress itself supports e-mail password recovery function, if the administrator account e-mail is valid, in the background login interface, click “forget the password?” Link, enter the correct e-mail address, you can receive a reset password with the message.
3, the WP directory under the wp-config.php file to delete, and then re-visit the site, which will allow you to re-install the last step, so you can get a new password.
4, log phpMyAdmin, find WP database wp_users table, where you can see the default user admin, its password is encrypted. At this time, we can modify this data, find the user_pass this domain, put it a long string of data deleted, write your password, such as 123456. At this point, you will see a function drop down box, select it as MD5. This is to put your password MD5 algorithm encryption, and then save. This way, through your domain name / wp-admin visit to the management of the entrance, with this password can be landing.
5, through the SQL statement to change the password. Log in to phpMyAdmin to enter the WordPress database and execute the following SQL statement:
UPDATE wp_users SET user_pass = MD5 (‘PASSWORD’) WHERE wp_users.user_login = ‘admin’ LIMIT 1;
6, use PHP to retrieve the password. PHP method in the final analysis is also the way SQL query changes, but to provide a user interface. Copy and save the following code as the password-resetter.php file, upload it to the WordPress root directory, and then run the file and enter the password to reset it.
<? php
// password resetter
include (“wp-config.php”);
include (“wp-blog-header.php”);
if (empty ($ _ POST [’emergency_pass’])) {
?>
<form method = “post”>
set admin password: <input name = “emergency_pass” type = “password” />
<input type = “submit” />
</ form>
<? php
} else {
$ sql = “UPDATE”. $ wpdb-> users. “‘SET user_pass ='” .md5 ($ _ POST [’emergency_pass’]). ” WHERE User_login = ‘admin’ “;
$ link = $ wpdb-> query ($ sql);
wp_redirect (‘wp-login.php’);
exit ();
}
?>

WordPress code to implement related articles

WordPress has a lot of plug-ins to achieve the relevant features of the article, the advantages of plug-in configuration is simple, but the speed of the site may cause some small impact, so many people still prefer to use code to achieve the required functions, but then again, Code to achieve there are shortcomings, is the configuration of complex, do not understand the code completely puzzled or can only copy someone else’s code, not as good as plug-ins.
Here I have compiled several code to achieve the relevant article method, which will detail the role of the various parts of the code, and how to customize the function you want, we hope to help, what questions can be published in this article Comments, I will reply to you in time. Before you start, note that all of the following methods output the HTML code format are in the form that you can modify as needed:
<ul id = “xxx”>
<li> * <a title=”>> Curseys 1″ rel=”bookmark” href=” paper> Link 1″> Article Title 1 </a> </ li>
<li> * <a title=” pages of paper2″ rel=”bookmark” href=” paper> link 2″> article title 2 </a> </ li>

</ ul>

Method 1: Label related
First get all the labels of the article, and then get the n articles under these tags, then the n article is related to the article on the article. Now you can see the WordPress related article plugins are used this method. The following is the implementation of the code:
<ul id = “tags_related”>
<? php
$ post_tags = wp_get_post_tags ($ post-> ID);
if ($ post_tags) {
foreach ($ post_tags as $ tag)
{
// Get the tag list
$ tag_list []. = $ tag-> term_id;
}
// Randomly get a label in the tag list
$ post_tag = $ tag_list [mt_rand (0, count ($ tag_list) – 1)];
// The method uses the query_posts () function to call the related article, the following is the parameter list
$ args = array (
‘tag__in’ => array ($ post_tag),
‘category__not_in’ => array (NULL), // not included in the category ID
‘post__not_in’ => array ($ post-> ID),
‘showposts’ => 6, // show the number of related articles
‘caller_get_posts’ => 1
);
query_posts ($ args);
if (have_posts ()):
while (have_posts ()): the_post (); update_post_caches ($ posts);?>
<li> * <a href=”<?php the_permalink();;> “rel =” bookmark “title =” <? php the_title_attribute ();?> “> <? php the_title ();?> </ a > </ li>
<? php endwhile; else:?>
<li> * No related articles </ li>
<? php endif; wp_reset_query ();}?>
</ ul>
Instructions for use: “does not include the classification of ID” refers to the article does not show the classification of the article, the peer NULL into the article can be classified ID, multiple ID comma separated by commas. Because the limit here only shows 6 related articles, so no matter to the query_posts () parameter tag__in how many values, are only show a label under the six articles, unless the first label has 1, the second label has 2, the third has 3. The The The The The So if this article has multiple tags, then we take the method is to randomly get a tag id, assigned to the tag__in this parameter, access to the six articles under the label.

Method 2: Classification related
The method is to obtain the article by the classification id, and then get the article under the category, to achieve the purpose of access to relevant articles.
<ul id = “cat_related”>
<? php
$ cats = wp_get_post_categories ($ post-> ID);
if ($ cats) {
$ cat = get_category ($ cats [0]);
$ first_cat = $ cat-> cat_ID;
$ args = array (
‘category__in’ => array ($ first_cat),
‘post__not_in’ => array ($ post-> ID),
‘showposts’ => 6,
‘caller_get_posts’ => 1);
query_posts ($ args);
if (have_posts ()):
while (have_posts ()): the_post (); update_post_caches ($ posts);?>
<li> * <a href=”<?php the_permalink(); ?> “rel =” bookmark “title =” <? php the_title_attribute ();
?> “> <? php the_title ();?> </a> </ li>
<? php endwhile; else:?>
<li> * No related articles </ li>
<? php endif; wp_reset_query ();}?>
</ ul>

wordpress latest, most comment and random log function trinity one

The latest log, the heat log, the random log these three functions in the function is very similar, nothing more than a sort of different, the latest log is sorted by the release time, hot comment log is sorted by the number of comments, random log is random Sorting. So I simply put these three functions into one, on the one hand to reduce the functionality.php code redundancy, on the other hand also facilitate their own management.
Copy the following function into functions.php in the WordPress theme directory:
function get_posts ($ orderby = ”, $ plusmsg = ”) {
$ get_posts = query_posts (‘posts_per_page = 10 & caller_get_posts = 1 & orderby =’. $ orderby);
foreach ($ get_posts as $ get_post) {
$ output = ”;
$ post_date = mysql2date ($ y month d day, $ get_post-> post_date);
$ commentcount = ‘(‘. $ get_post-> comment_count. ‘comments’);
$ post_title = htmlspecialchars (stripslashes ($ get_post-> post_title));
$ permalink = get_permalink ($ get_post-> ID);
$ output. = ‘<li> <a href=”‘. $permalink.'” title=”‘.$post_title.'”>’. $ post_title. ‘</a>’. $$ plusmsg. ‘</ li;
echo ‘<ul>’. $ output. ‘</ ul>’;
}
wp_reset_query ();
}
The calling method is as follows:
<? php
// the latest log
get_posts ($ orderby = ‘date’, $ plusmsg = ‘post_date’);
// hot comment log
get_posts ($ orderby = ‘comment_count’, $ plusmsg = ‘commentcount’);
// random log
get_posts ($ orderby = ‘rand’, $ plusmsg = ‘post_date’);
?>
You can see that they share a function of the three, but only different parameters Bale, such as the title, the latest, hot evaluation, random log function Trinity is completed.
Here I introduce the latest WordPress, hot comment, random log three-in-one function set in the time range of 30 days, the effect of the site on the sidebar of the log on it, all in 30 days within.
First put the following function in the WordPress theme folder in the functions.php:
function filter_where ($ where = ”) {
$ where. = “AND post_date>”. date (‘Y-m-d’, strtotime (‘- 30 days’)).
return $ where;
}
function some_posts ($ orderby = ”, $ plusmsg = ”, $ limit = 10) {
add_filter (‘posts_where’, ‘filter_where’);
$ some_posts = query_posts (‘posts_per_page =’. $ limit. ‘& caller_get_posts = 1 & orderby =’. $ orderby);
foreach ($ some_posts as $ some_post) {
$ output = ”;
$ post_date = mysql2date ($ y month d day), $ some_post-> post_date);
$ commentcount = ‘(‘. $ some_post-> comment_count. ‘comments’);
$ post_title = htmlspecialchars (stripslashes ($ some_post-> post_title));
$ permalink = get_permalink ($ some_post-> ID);
$ output. = ‘<li> <a href=”‘. $permalink.'” title=”‘.$post_title.'”>’. $ post_title. ‘</a>’. $$ plusmsg. ‘</ li;
echo $ output;
}
wp_reset_query ();
}
You can see the second line of 30 refers to the last 30 days, you can also modify the time according to your own needs. As for the call and upgrade before the same, the following is just more than the last one $ limit parameters:
<? php
// the latest log
some_posts ($ orderby = ‘date’, $ plusmsg = ‘post_date’, 10);
// hot comment log
some_posts ($ orderby = ‘comment_count’, $ plusmsg = ‘commentcount’, 10);
// random log
some_posts ($ orderby = ‘rand’, $ plusmsg = ‘post_date’, 10);
?>
OK, then I want to click on the highest ranking is also changed to 30 days ranking, so often to patronize the user should be more reasonable it, or it seems to look at a few, the title to see rotten.

Useful SQL query in WordPress

WordPress stores all of its information snippets (including articles, pages, comments, blog links, plugin settings, etc.) in the MySQL database. Although WordPress users can edit the above information snippet through the site background editing. to a certain degree.
But assuming that you have hundreds of articles on the WordPress site, and you need to change the whole station range, then edit from the background is a bit time-consuming effort, and the probability of mistakes will increase. The best way is to enter the WordPress MySQL database to perform the necessary queries (changes). Through MySQL can quickly complete the above tasks, for you to save more time.
The following is to introduce some time-saving WordPress SQL query method.

Pre-backup
The WordPress database stores all the articles you’ve posted carefully, all the comments from your readers, and all the personalizations you’ve made to your site. So, no matter how confident you are, please remember that you must back up the WordPress database in advance. You can back up the backup plugin.

Add a custom field for all articles and pages
This code can add a custom field to all articles and pages in the WordPress database. What you need to do is replace the ‘UniversalCutomField’ in the code with the text you want, and change the ‘MyValue’ to the desired value.
INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
SELECT ID AS post_id, ‘UniversalCustomField’
AS meta_key ‘MyValue AS meta_value FROM wp_posts
WHERE ID NOT IN (SELECT post_id FROM wp_postmeta WHERE meta_key = ‘UniversalCustomField’);
If you only need to add a custom field for the article, you can use the following code:
INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
SELECT ID AS post_id, ‘UniversalCustomField’
AS meta_key ‘MyValue AS meta_value
FROM wp_posts WHERE ID NOT IN
(SELECT post_id FROM wp_postmeta WHERE meta_key = ‘UniversalCustomField’)
“ AND post_type = ‘post’;
If you only need to add a custom field for the page, you can use the following code:
INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
SELECT ID AS post_id, ‘UniversalCustomField’
AS meta_key ‘MyValue AS meta_value
FROM wp_posts WHERE ID NOT IN
(SELECT post_id FROM wp_postmeta WHERE meta_key = ‘UniversalCustomField’)
AND `post_type` = ‘page’;

Delete the article meta data
When you install or remove the plug-in, the system stores the data through the article meta tag. Plug-in is deleted, the data will remain in the post_meta table, of course, then you no longer need these data, you can delete it. Remember to replace the ‘YourMetaKey’ in the code with the corresponding value you need before running the query.
DELETE FROM wp_postmeta WHERE meta_key = ‘YourMetaKey’;

Find useless tags
If you delete the old article in the WordPress database, the article will remain in the database and will appear in the tag list / tag cloud, as in the case of the previous plugin. The following query can help you find useless tags.
SELECT * From wp_terms wt
INNER JOIN wp_term_taxonomy wtt ON wt.term_id = wtt.term_id
WHERE wtt.taxonomy = ‘post_tag’ AND wtt.count = 0;

Batch delete spam comments
Execute the following SQL commands:
DELETE FROM wp_comments WHERE wp_comments.comment_approved = ‘spam’;

Bulk delete all unaudited comments
This SQL query will delete all unaudited comments on your site without affecting the comments that have been reviewed.
DELETE FROM wp_comments WHERE comment_approved = 0

No comment on earlier articles
Specifies that the value of comment_status is open, closed, or registered_only. Also need to set the date (modify the code in 2010-01-01):
UPDATE wp_posts SET comment_status = ‘closed’ WHERE post_date <‘2010-01-01’ AND post_status = ‘publish’;

Disable / activate trackback and pingback
Specifies that the value of comment_status is open, closed, or registered_only.
Activate pingbacks / trackbacks for all users:
UPDATE wp_posts SET ping_status = ‘open’;
Disable pingbacks / trackbacks for all users:
UPDATE wp_posts SET ping_status = ‘closed’;

Activate / deactivate Pingbacks & Trackbacks before a date
Specifies that the value of ping_status is open, closed, or registered_only. Also need to set the date (modify the code in 2010-01-01):
UPDATE wp_posts SET ping_status = ‘closed’ WHERE post_date <‘2010-01-01’ AND post_status = ‘publish’;

Delete comments for specific URLs
When you find a lot of spam comments with the same URL link, you can use the following query to delete these comments at once. % Means that all URLs containing the string within the “%” symbol will be deleted.
DELETE from wp_comments WHERE comment_author_url LIKE “% nastyspamurl%”;

Identify and remove articles from “X” days ago
Find all articles for “X” days (note that replace X with the corresponding value):
SELECT * FROM `wp_posts`
WHERE `post_type` = ‘post’
AND DATEDIFF (NOW (), `post_date`>> X

Remove all articles from “X” days ago:
DELETE FROM `wp_posts`
WHERE `post_type` = ‘post’
AND DATEDIFF (NOW (), `post_date`>> X

Remove unwanted short codes
When you decide not to use short code, they will not disappear automatically. You can use a simple SQL query command to remove all unwanted short codes. Replace “tweet” with the corresponding short code name:
UPDATE wp_post SET post_content = replace (post_content, ‘[tweet]’, ”);

Change the article to page
Still just through PHPMyAdmin run a SQL query can get:
UPDATE wp_posts SET post_type = ‘page’ WHERE post_type = ‘post’
Convert the page to article:
UPDATE wp_posts SET post_type = ‘post’ WHERE post_type = ‘page’

Change the author attribute on all articles
First, the author’s ID is retrieved by the following SQL command:
SELECT ID, display_name FROM wp_users;
After successfully getting the author’s new ID, insert the following command, remember to replace NEW_AUTHOR_ID with the new author ID, and replace the old author ID with OLD_AUTHOR_ID.
UPDATE wp_posts SET post_author = NEW_AUTHOR_ID WHERE post_author = OLD_AUTHOR_ID;

Batch delete article revision history
Article revision history can be very useful to save, it can be very annoying. You can manually delete the revision history, you can also use the SQL query to save their time.
DELETE FROM wp_posts WHERE post_type = “revision”;

Disable / activate all WordPress plugins
Activate a plug-in and found unable to log in WordPress management panel, and try the following query command, it will immediately disable all plug-ins, so you re-login.
UPDATE wp_options SET option_value = ‘a: 0: {}’ WHERE option_name = ‘active_plugins’;

Change the target URL for the WordPress site
After moving the WordPress blog (template file, upload content & database) from one server to another, then you need to tell WordPress your new blog address.
When using the following command, note that http://www.old-site.com is replaced by your original URL and http://www.new-site.com is replaced by a new URL.
First of all:
UPDATE wp_options
SET option_value = replace (option_value, ‘http://www.old-site.com’, ‘http://www.new-site.com’)
WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
Then use the following command to change the URL in wp_posts:
UPDATE wp_posts SET guid = replace (guid, ‘http: //www.old-site.com’, ‘http: //www.new-site.com);
Finally, search the contents of the article to ensure that the new URL link is not confused with the original link:
UPDATE wp_posts
SET post_content = replace (post_content, ‘http://www.ancien-site.com’, ‘http://www.nouveau-site.com’);

Change the default user name Admin
Replace one of your YourNewUsername with a new username.
UPDATE wp_users SET user_login = ‘YourNewUsername’ WHERE user_login = ‘Admin’;

Manually reset the WordPress password
If you are the only author on your WordPress site and you have not modified the default username, you can use the following SQL query to reset the password (replace the PASSWORD with the new password):
UPDATE `wordpress`.`wp_users` SET` user_pass` = MD5 (‘PASSWORD’)
WHERE `wp_users`.`user_login` =` admin` LIMIT 1;

Search and replace article content
OriginalText replaced with replaced content, ReplacedText replaced with the target content:
UPDATE wp_posts SET `post_content`
= REPLACE (`post_content`,
‘OriginalText’,
‘ReplacedText’);

Change the image URL
The following SQL command can help you modify the image path:
UPDATE wp_posts
SET post_content = REPLACE

WordPress only shows the friend links on homepage

Do seo optimization, links to the whole station link and just the home page link is very different. Will be decentralized. Many common wordpress templates are set links throughout the station, so we need to achieve wordpress only show links in the home page and need to toss the wordpress template.
Here for everyone to say that modify the wordpress link seo optimization techniques.

Method 1: Modify the theme source code
In the background to find the location of the link in the theme of the location, background – appearance – editor can be found. The general theme of the link is on the side (sidebar.php), also on the footer (footer.php), according to their own theme to find the link code: <? Php wp_list_bookmarks ();
After that, replace the following code:
<? php if (is_home ()) {?>
<? php wp_list_bookmarks ();?>
<? php}?>
Code explanation: is_home (); Description This code contains links only in the home page.
But I use this code to test, no effect, check the content page is still a link, always want to understand what is the problem? After asking the Supreme, wordpress a lot of people, and finally find a solution to the problem.
As long as the is_home (); before adding a wp_reset_query (); can be resolved, the perfect get.
The final code is as follows:
<? php wp_reset_query (); if (is_home ()) {?>
<? php wp_list_bookmarks ();?>
<? php}?>

Method 2: Plugin settings
1, plug-in name: Widget Logic in the background search installation start.
2, after the figure to speak, background settings. Fill in the following options is_home () &&! Is_paged () and then click Save on the set is completed

WordPress link settings map
3, some commonly used display instructions
is_home () home page
is_admin () administrator account
is_single () article page
is_page () page
is_404 () page can not find page
is_search () search results page
is_feed () subscription page
The is_category (5) only in the ID non-5 classification display
is_category () article classification page
is_tag () article tab
is_archive () archive page
The following explains the meaning of some symbols: || that or, && that and, that is not.

WordPress no plugin automatically displays thumbnails

Like toss to modify the wordpress theme friends, certainly encountered such a problem, would like to show thumbnails in the home page, there are plug-ins can be achieved, but not easy to operate and control, after all, the code is written, and today to share with you, No plug-in, pure code is how to achieve the first page of the article thumbnails, the method is very simple, even if you do not understand the code, according to the steps can also be. Of course, the thumbnail is selected in the article in the first picture, if the article does not contain pictures, show the default picture, so you have to set a default picture location.
Into the topic, start to add the first page thumbnail, simple 3 steps can be achieved:

The first step: find the use of the theme template function.php file in the <? Php and?> Add the following code:
function thumb_img ($ soContent) {
$ soImages = ‘~ <img [^ \>] * \ /> ~’;
preg_match_all ($ soImages, $ soContent, $ thePics);
$ allPics = count ($ thePics [0]);
if ($ allPics> 0) {
echo “<span id = ‘thumb’>”;
echo $ thePics [0] [0];
echo ‘</ span>’;
}
else {
echo “<span id = ‘thumb’>”;
echo “<img src = ‘”;
echo bloginfo (‘template_url’);
echo “/images/thumb.gif ‘> </ span>”;
}
}
This is a method of displaying thumbnails, automatically retrieving the first picture of the article, and if you do not show the current theme /images/thumb.gif so you should have this thumb.gif picture ready.

The second step: find the index.php file that is the first page file, find the_content (); or similar code before it add the following code:
thumb_img ($ post-> post_content);
This call the method just now, in fact, the thumbnail has been completed. But you see the effect must be very unexpected, the size of the picture should be no control, will be ugly.

Step 3: Add thumbnail style CSS code:
This is the cloud station used in the thumbnail style, you can make do with the use, and then modify it
#thumb {margin: 5px 15px 5px 5px; width: 145px; height: 120px; border: 3px solid #eee; float: left; overflow: hidden;}
#thumb img {max-height: 186px; max-width: 186px}

Well, so there is a thumbnail showing a kind of show it.