WordPress Timed Release Articles Fails How to do?

wordpress program, there is a great advantage is that this program can be released regularly, when we can not update the site, the regular release can make the site automatically updated, is conducive to SEO optimization and user experience.

How to publish regularly?
In the “Publish” option on the right side of the interface that publishes the article, click “Edit” on the right side of “Publish Now”. The interface shown in the following figure will appear. You can select the date and time of publication.

Timed release failure how to do?

Sometimes because of the server, or the system itself, the conflict of the code and plug-in conflict, will make our timing release failure, that is, to the scheduled time, the article is not released, the following teach you how to solve:
Method 1: Modify the /wp-includes/cron.php system file
Open the wp-includes directory below the cron.php file, find the “timeout” code:

  1. wp_remote_post( $cron_urlarray( ‘timeout’ => 0.01, ‘blocking’ => false, ‘sslverify’ => apply_filters( ‘https_local_ssl_verify’, true ) ) );

Change the value of the code after the 0.01 than 0.01 can be changed, it can be modified to 10.00.
But after using this method after each update wordpress version must be re-modified after this file is not recommended.

Method 2: Use the WP Missed Schedule plugin

Download WP Missed Schedule, the installation can be enabled, simple and rude effective, recommended!

Here you can buy WoW boost at Ozyboost premium service ขนมเด็ก

Some learning methods about WordPress

First of all, WordPress is a foreign open source CMS.
It is some powerful, strong to I do not know how to describe it. It can almost complete all the types of websites you think of. This is no exaggeration, our team has used it to complete a single 6-digit project.
It’s some mighty, powerful and we do not know how to get close to it, familiar with it, learn and apply it. I have also light up the night war, Bing lamp candle. At the end, little success.
Below, I come to sum up my way to learn WordPress, I hope you can help, even if it is a little bit of guidance, but also excellent.
WordPress is a foreign CMS, there are almost all of its website abroad, I list a few I often go to the site.
Official website: https: //wordpress.org
Here on the latest information on the WordPress, the latest version of the program is also on the top of the starting.
Official documentation: https: //codex.wordpress.org/Main_Page
Here on the side of WordPress latest, most accurate, the most complete, authentic description. Prior to this, this document is in Chinese version, but more than why, recently seems to have been canceled.
But I still recommend to see the original English, because it is the most accurate.
Official code reference: https: //developer.wordpress.org/reference/
Here are examples of WordPress function, description, very detailed.
Take our most commonly used add_action function, its description is very detailed. Its address is: https: //developer.wordpress.org/reference/functions/add_action/
Here is a detailed description of the add_action function which parameters accepted, what is the type of parameters, what is the value of the return, which is the source of which documents, the first few lines. In the inside have a detailed description.
If you want to learn WordPress in depth, it is recommended that you look at this site, then you will find some wonderful things.
Official forum: https: //wordpress.org/support/
Forums from the installation of the program to the plug-in development, from the theme template to a variety of troubleshooting has a very detailed partition. And this forum is very active.
PHP official website: php.net
WordPress is based on the PHP language to develop, there is a better PHP basis to understand WordPress code, otherwise it is tantamount to look at the book.
Finally, I want to introduce you to a black technology! Technology! Technology! The
google.com is google.com you are not wrong. Baidu localization, although doing a good job, but in the search for technical articles or when the difference is hundreds of kilometers. I found out all the reprint is not much to say ok! The The
It is very difficult for us to find a solution to the problem directly through the documentation before we have any problems before we are in contact with the problem.
At this time, we have to make use of the search. You may have problems before you have and you encounter the same problem people, they may be published on the Internet for help, may also have left a solution. Even if these are not, the search engine can also give you a solution to the problem.
Well, today, first wrote here, there is time to share with you to learn the method.
Yes, the top of the site may be due to some reasons can not be accessed, here to recommend a tool to the wall. Ladder VIP address is: https: //www.yuntivip.com, everyone to buy their own use.

Solution: WordPress WPImageEditorImagick instruction injection vulnerability

Vulnerability Name: wordpress WP_Image_Editor_Imagick instruction injection vulnerability
In the /wp-includes/media.php _wp_image_editor_choose function internally found (probably at 2898 lines):

  1. $implementations = apply_filters( ‘wp_image_editors’, array( ‘WP_Image_Editor_Imagick’ ,  ‘WP_Image_Editor_GD’ ) );

change to:

  1. $implementations = apply_filters( ‘wp_image_editors’, array(  ‘WP_Image_Editor_GD’ ,’WP_Image_Editor_Imagick’ ) );


wordpress removes the wp-json link and the wp-embed.min.js file

Recently updated the latest version of the wordpress 4.4, update what function I do not know, I know I do not have access to, but found that there are several functions inside the link function, I do not have access. So we removed him, mainly more REST API (through the REST API can easily access the site’s data), wp-json link, embeds function (embeds function can allow more convenient reference to third-party resources) wp-embed.min.js file.
We do not have to load it to do what, but also affect the site to read the speed, then we talk about how to prohibit out.
First talk about the disabled REST API, remove the wp-json link method, add the following code to the theme functions.php file to disable the REST API and remove the head inside the output of the link information:

  1. add_filter(‘rest_enabled’, ‘_return_false’);
  2. add_filter(‘rest_jsonp_enabled’, ‘_return_false’);
  3. remove_action( ‘wp_head’, ‘rest_output_link_wp_head’, 10 );
  4. remove_action( ‘wp_head’, ‘wp_oembed_add_discovery_links’, 10 );

Disable embeds is actually more complex (code more), the official and even developed a plug-in for this, we can use the plug-in to disable: Disable Embeds, if you do not want to use plug-ins, then plug the code inside the copy to the theme functions.php File can be.

  1. function disable_emojis() {
  2. remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
  3. remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );
  4. remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );
  5. remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );
  6. remove_filter( ‘the_content_feed’, ‘wp_staticize_emoji’ );
  7. remove_filter( ‘comment_text_rss’, ‘wp_staticize_emoji’ );
  8. remove_filter( ‘wp_mail’, ‘wp_staticize_emoji_for_email’ );
  9. add_filter( ‘tiny_mce_plugins’, ‘disable_emojis_tinymce’ );
  10. }
  11. add_action( ‘init’, ‘disable_emojis’ );
  12. /** 
  13. * Filter function used to remove the tinymce emoji plugin. 
  14. */
  15. function disable_emojis_tinymce( $plugins ) {
  16. if ( is_array$plugins ) ) {
  17. return array_diff$pluginsarray( ‘wpemoji’ ) );
  18. else {
  19. return array();
  20. }
  21. }
  22. function disable_embeds_init() {
  23. global $wp;
  24. $wp->public_query_vars = array_diff$wp->public_query_vars, array( ’embed’, ) );
  25. remove_action( ‘rest_api_init’, ‘wp_oembed_register_route’ );
  26. add_filter( ’embed_oembed_discover’, ‘__return_false’ );
  27. remove_filter( ‘oembed_dataparse’, ‘wp_filter_oembed_result’, 10 );
  28. remove_action( ‘wp_head’, ‘wp_oembed_add_discovery_links’ );
  29. remove_action( ‘wp_head’, ‘wp_oembed_add_host_js’ );
  30. add_filter( ‘tiny_mce_plugins’, ‘disable_embeds_tiny_mce_plugin’ );
  31. add_filter( ‘rewrite_rules_array’, ‘disable_embeds_rewrites’ ); }
  32. add_action( ‘init’, ‘disable_embeds_init’, 9999 );
  33. function disable_embeds_tiny_mce_plugin( $plugins ) { return array_diff$pluginsarray( ‘wpembed’ ) ); }
  34. function disable_embeds_rewrites( $rules ) { foreach ( $rules as $rule => $rewrite ) { if ( false !== strpos$rewrite, ’embed=true’ ) ) { unset( $rules$rule ] ); } }
  35. return $rules; }
  36. function disable_embeds_remove_rewrite_rules() { add_filter( ‘rewrite_rules_array’, ‘disable_embeds_rewrites’ ); flush_rewrite_rules(); }
  37. register_activation_hook( __FILE__, ‘disable_embeds_remove_rewrite_rules’ );
  38. function disable_embeds_flush_rewrite_rules() { remove_filter( ‘rewrite_rules_array’, ‘disable_embeds_rewrites’ ); flush_rewrite_rules(); }
  39. register_deactivation_hook( __FILE__, ‘disable_embeds_flush_rewrite_rules’ );

Every time you update the wordpress version will be more things, such as the previous emoji, and are input on the page content, more or less will affect the speed, our blog is basically updated under the article, engage in too much responsibility for the excessive, Not to get rid of REST API and embeds, for the user experience, so that the website faster display of our code on the OK.

WordPress front end user center often used data and access methods

In the development of ordinary WordPress theme, we have ready-made theme can refer to, but the development of WordPress front-end user center, we are not easy to find a reference, probably because WordPress front-end user center needs no common theme The This article will introduce some of the development of WordPress front-end user center users often to some data acquisition method.

Global variables:

  1. $authordata
  2. $post
  3. $wp_query

Get the author archive page link

  1. echo get_author_posts_url( $authordata->ID );

Get the author’s nickname

  1. echo esc_attr( $authordata ->display_name )

Get the number of comments, use in loop:

  1. echo $post->comment_count

Get comment link, loop use:

  1. comments_link()

Get the current login user information

  1. $current_user = wp_get_current_user();

Gets the user information that needs to be operated

  1. global $wp_query;
  2. $author = $wp_query->get_queried_object();

Above is the development of front-end user center wordpress time often used in some of the data acquisition method, of course, this is only part of which I will be in the development of front-end user center when the accumulation gradually added for your reference.

Code to achieve WordPress automatic keywords keywords and description

The following code to achieve the label as a keyword; to summary for the description, if not fill out the abstract, then automatically intercept the article before the 200 words for the description. (Tutorial transferred from: DeveWork)

Code to achieve WordPress automatic keywords and description:
The following code put under your theme funtions.php the last one?

// Automatic keywords and description
function get_cats_name () {
$ allcats = get_categories ();
foreach ($ allcats as $ category)
$ keywords [] = $ category-> cat_name;
return $ keywords;
// utf8 substr
function utf8Substr ($ str, $ from, $ len) {
return preg_replace (‘# ^ (?: [x00-x7F] | [xC0-xFF] [x80-xBF] +) {0,’. $ from. ‘}’.
(): [x00-x7F] | [xC0-xFF] [x80-xBF] +) {0, ‘. $ len.’}). * # s’
‘$ 1’, $ str);
// Meta SEO
function meta_SEO () {
global $ post;
$ output = ”;
if (is_single ()) {// if it is an article page
$ keywords = ”;
$ description = ”;
if ($ post-> post_excerpt) {// If the article abstract exists on the article summary to describe
$ description = $ post-> post_excerpt;
$ description = str_replace (“rn”, “”, $ description);
$ description = str_replace (“n”, “”, $ description);
$ description = str_replace (“” “,” ‘”, $ description);
$ description. = ‘…’;
} else {// If the article summary does not exist, truncate the article before the 200 words for the description
$ description = utf8Substr (strip_tags ($ post-> post_content), 0,200);
$ description = str_replace (“rn”, “”, $ description);
$ description = str_replace (“n”, “”, $ description);
$ description = str_replace (“” “,” ‘”, $ description);
$ description. = ‘…’;
$ tags = wp_get_post_tags ($ post-> ID); // take the article tag
foreach ($ tags as $ tag) {
$ keywordarray [] = $ tag-> name;
// Use the article tag as a keyword
$ keywords = implode (‘,’, array_unique ((array) $ keywordarray));
} else {// if it is not an article page
$press = ‘wordpress, wordpress theme, wordpress tutorial, wordpress theme download, wordpress blog theme, wordpress corporate theme, wordpress theme custom’; // quotation marks between your blog keywords,
$ description = ‘theme cat, dedicated to the majority of users to provide the latest and most complete wordpress theme’; / / quotation marks between your blog to write a simple description, do not over 200 words
// Output keywords
$ output. = ‘<meta name = “keywords” content = “‘. $ keywords. ‘” />’.
$ output. = ‘<meta name = “description” content = “‘. $ description. ‘” />’.
// output description
echo “$ outputn”;
add_action (‘wp_head’, ‘meta_SEO’); // add the meta_SEO function to the header

The contents of lines 43 and 44 need to be modified according to your website.

Prohibit wordpress4.4 + version automatically generates a 768 pixel thumbnail

4.4 version later, wordpress added a responsive picture function, the purpose is to allow the picture to adapt to the phone, tablet and other different screens, you upload the picture will automatically generate a 768 pixel thumbnail, but I do not want this feature, the Thumbnail size is fully adjusted to 0, prohibit wordpress automatically generate thumbnails, upload pictures or will generate a 768 pixel thumbnails.

This problem I find a long time did not find a solution to study the day, finally resolved.
In the document wp-admin \ includes \ schema.php Lane in the following code, you can see is 4.4 new features.

  1. // 4.4.0
  2.     ‘medium_large_size_w’ => 768,
  3.     ‘medium_large_size_h’ => 0,

This is the default option to install wordpress, but there is no place to change in the background, there is no change code, because it has been deposited into the database, so go into the database.
Enter the command to change the value of medium_large_size_w to 0 on the line
SQL commands are as follows:

  1. SELECT * FROM `wp_options` where option_name=’medium_large_size_w’

Prohibit wordpress generation 768 pixel thumbnails can effectively save the site space, especially those pictures of many sites (such as the theme of the cat wordpres theme download station) need to prohibit this thumbnail.

Simple and atmospheric responsive blog theme Dobby

Dobby is a free, open-source, self-adaptive theme that he can access with a friendly experience from any browser. Dobby upholds the characteristics of concentrating on writing and reading. The simple and generous structure of the homepage allows blogs to stand out in a cluttered environment. The Dobby theme has a powerful theme background control platform built in. It can easily set keywords and site descriptions, custom top styles, powerful bottom social components, and beautiful blog subscription features to make your website more distinctive. More pages with styles waiting for you to discover!

Theme features

  • Responsive design, perfect display on computer, tablet and mobile phone
  • Custom header picture
  • Built-in picture carousel
  • Footer socialization gadget
  • Built-in multiple ad bar gadgets
  • Powerful background customization
  • Custom theme color
  • Supports WordPress 3.5+, and supports the latest WordPress 4.9

Get theme

GitHub: https://github.com/Vtrois/Dobby

WordPress site replacement domain name of some of the operating methods

In the group to see a lot of friends asked, wordpress to change the domain name to do so? Background settings – routine changes in the domain name, the station can not open, and this is why? Do this
In fact, wordpress for domain name to the database to operate, first of all, to analyze the domain name for several common situations.

One, for space for domain name
1, if it is the above problem, the package backup the old space ftp all the files, into the old station database phpmyadmin export your site database sql file;
2, will be the backup of the ftp all files uploaded to the new space FTP, the backup of the sql uploaded to the new space in the database phpmyadmin;
3, open the new space ftp site root directory to find wp-config.php file, edit it (php file do not use txt to edit), edit the configuration of the new database connection information;
4, to the new space database phpmyadmin Lane, do sql batch for domain name processing (see the following tutorial two)

Second, only for domain name, no room for change
Open the new space of phpmyadmin (database control panel)
And then select the new database name, click, enter wp_ at the beginning of the table is greater than or equal to 11, and then select the sql in the tab, as shown in Figure:

Then is the order for the order of sql batch processing:


  • UPDATE wp_options SET option_value = replace( option_value, ‘http://www.old.com’, ‘http://www.new.com’ ) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
  • UPDATE wp_posts SET post_content = replace( post_content, ‘http://www.old.com’, ‘http://www.new.com’ ) ;
  • UPDATE wp_posts SET guid = replace( guid, ‘http://www.old.com’, ‘http://www.new.com’ ) ;

old on behalf of the old domain name, new on behalf of the new domain name, the above implementation of the statement will be modified to your own, and then click on the implementation can be!
To this step, the basic OK OK. The The Of course, for the way the domain name will encounter a variety of problems, there can be a problem to join our technical group to help Kazakhstan!



WordPress links are automatically added Noopener Noreferrer

I do not know if there is no need to put the chain in the article, taking into account the problem of SEO will generally give the site an article outside the chain automatically nofollow function, nofollow is an HTML tag attribute value. The meaning of this tag is to tell the search engine “Do not follow the links on this page or do not track this particular link.
Beard recently in the editorial website when the article found outside the chain can not automatically add nofollow attribute, after some research is the new version of the wordpress problem.
WordPress automatically adds the new Noopener Noreferrer attribute (resulting in the nofollow property failure) for all links that require a new window in the most recent version update.
Noopener Noreferrer property is not a new release standard, but v4.7.4 version of the WordPress editor will add the default by default.
This property is mainly used to prevent new windows from opening links when there may be phishing attacks, so as a security content WordPress gives added.
But after the addition of the new tab page will not be able to follow the conventional method to track the source page, which in the attribute field has been able to see: No Refer.
After the upgrade to WordPress v4.7.4 version of the original release of the contents of the new window link does not automatically add Noopener Noreferrer.
But if it is a new article or you modify the contents of the previous release, then the new window link will add Noopener Noreferrer.

Please add this code to the bottom of your wordpress theme at function.php and save and upload it

  1. //WordPress links auto add Noopener Noreferrer
  2. add_filter(‘tiny_mce_before_init’,’tinymce_allow_unsafe_link_target’);
  3. function tinymce_allow_unsafe_link_target( $mceInit ) {
  4. $mceInit[‘allow_unsafe_link_target’]=true;
  5. return $mceInit;
  6. }

Add the newly released content after the link if set to a new window open then the Noopener Noreferrer property will no longer be added automatically.
If the previously published article has been attached to the property even after the addition will not automatically remove, you need to manually edit and then delete the new attribute.
That is, manually edit the article and switch the editor to text mode and then rel = “noopener noreferrer” deleted and then save the update on the line.

WordPress website on the line before you have to complete these five things

In the site of the user exchange group which chat, found that many people always ask a question: the site before the line, what needs to be done? I think this question makes sense. According to past experience to sum up, share the theme of the cat’s friends.
Each site may have its own differences, but there are a lot in common. For the WordPress site, before you go online, you should complete the following five things:

1. prohibit search engine index.
This is because when you just started building the site, it is not suitable for search engine content included. At this time, the site content has not yet been built, some text is only some of the presentation. If the search engine contains the content, it is terrible, because the user to see such a content will have a bad impression on your site. You can in the WordPress management background [settings] -> [read] page settings: shielding search engine index site content. Of course, after everything is ready for the site, do not forget to modify the settings here, allowing the search engine to index the site content.

2. Check the website link.
Make sure that all links within the site are working properly. If the site has a failed link, it will affect the site’s SEO ranking. We have a few days ago to recommend you Broken Link Checker free plug-in, can help you complete this work. (To the bottom of this article)

3. Modify the thumbnail size.
When you change the WordPress theme to the site, it’s important to modify the thumbnail size because the thumbnails of many topics are not the same size.


4. Check the contents of the website twice.
Including the sidebar of the site, footer area, and navigation bar. We often leave some text errors, especially when you stare at the same site content text for a week, so please check it carefully.

5. View the website with your phone.
If conditions permit, try to check the appearance of your website with a variety of different mobile phones and Internet devices. Otherwise, if you only have a large screen PC, you can also try to continuously reduce the width of the browser to see the appearance of the site in different sizes.
If you have any special experience, welcome to communicate with us through the message.

How to modify the name of the WordPress default role

WordPress provides five default roles, different roles have different permissions, decide what they can and can not do; for example: whether the right to write or review other people’s articles; whether the right to replace the site theme. However, WordPress does not allow you to directly modify the default role name. However, it is not difficult to do it, the theme cat today will tell you how to modify these default roles.
WordPress default 5 roles are: Admin, Editor, Author, Contributor, Contributor, Subscriber.

Why do I need to customize the role name?
For users who use WordPress to build a personal blog, there is no need to modify these role names, because he generally does not use these. But for the corporate website is necessary.
WordPress after the acquisition of WooCommerce, the use of WordPress to build foreign trade sites and online mall users will be further increased. If you use WordPress to help customers to do an e-commerce site, site visitors (that is, potential customers) will be very strange, why their identity is Subscriber (subscribers)? Therefore, this time must deal with this problem.
To modify the default role of WordPress, you only need to write down the code to copy the functions.php file or the site-specific plugin for the theme you are using:

  1. function wps_change_role_name() {
  2.   global $wp_roles;
  3.   if ( ! isset( $wp_roles ) )
  4.    $wp_roles = new WP_Roles();
  5.   $wp_roles->roles[‘contributor’][‘name’] = ‘Owner’;
  6.   $wp_roles->role_names[‘contributor’] = ‘Owner’;
  7. }
  8. add_action(‘init’, ‘wps_change_role_name’);

The name of the Contributor role is changed to Owner (owner, owner). Here you can also use the Chinese, but must remember to save the file as utf8 no bom format, otherwise the Chinese may be displayed as garbled.
This code comes from Kevin Chard’s website. And then look back at the role of the site, turned into this:

However, it should be noted that this code is only the name of the Contributor role modified, and will not modify the corresponding permissions, nor add a new role, and even the role of slug (abbreviation, alias) will not modify.

No plug-in WordPress15 practical tips (1)

The power of WordPress is that you can use plug-ins to easily extend the functionality of your site. But sometimes, we need to modify or add the function, just a few lines of code can be done. Today, the theme cat will give you 15 very practical WordPress skills, and do not need any WordPress plugin.
In the WordPress official plugin directory, there are about 40,000 free WordPress plugins that can extend WordPress functionality. In addition, there are many can not count the number of charge plugins. Through these plug-ins, basically can meet the needs of the vast majority of the site.
But sometimes we need some of the features, no need to plug the same can be done. Below, we will give you some very useful WordPress skills, tips, tips, no need to install any WordPress plugin.
This article is longer, divided into two release. This article is the first chapter, the next article will be released within a week:

WordPress Code Tuning: Administrator and Manage Background (Console, Dashboard)
1. Modify the Logo (logo) in the WordPress website login interface
First introduce a technique related to website branding: If you plan to modify your website (or your client’s website) login interface in the WordPress Logo, the following code is just right for you. Use it very simply, just copy the following code into the funcitons.php file on your site’s theme, or in a plugin dedicated to your site:

  1. function my_custom_login_logo() {
  2.     echo ‘&lt;style type=&quot;text/css&quot;&gt;
  3.         h1 a { background-image:url(‘.get_bloginfo(‘template_directory’).’/images/custom-login-logo.png) !important; }
  4.     &lt;/style&gt;’;
  5. }
  6. add_action(‘login_head’, ‘my_custom_login_logo’);

And then do their own Logo, named custom-login-logo.png, upload to the use of the theme directory within the images folder. This code we introduced, but also introduced how to modify the default Logo corresponding to the URL.

2. Modify the Logo of the WordPress management background (dashboard)
Want a WordPress site to stay closer to your business, feel more cordial? Replace WordPress management background (console, dashboard) in the upper left corner of the default WordPress Logo it. Many plugins can do this, but the following code can also directly achieve this function. Similarly, copy the following code into the theme’s funcitons.php file, or in the theme-specific plugin:

  1. function custom_admin_logo() {
  2.   echo ‘&lt;style type=&quot;text/css&quot;&gt;
  3.           #header-logo { background-image: url(‘.get_bloginfo(‘template_directory’).’/images/admin_logo.png) !important; }
  4.         &lt;/style&gt;’;
  5. }
  6. add_action(‘admin_head’, ‘custom_admin_logo’);

Then, you want to use the WP management background in the logo named admin_logo.png, uploaded to the use of the theme directory within the images folder.

3. Close the WordPress login box prompt function
To ensure the security of the WordPress site, it is important that we have written many articles on how to enhance the security of the site. We introduced this technique, but it is a very simple step, but also very useful. The default emptied, when you want to enter the account information log WordPress background, if you enter the information is wrong, WordPress will tell you the error message: the user name does not exist, or password error. This trick is to turn off such tips to enhance the security of the WordPress site.
To disable WordPress login error message, you need to copy the following code into the theme of the funcitons.php file, or within the site-specific plugin:

  1. function no_wordpress_errors(){
  2.   return ‘GET OFF MY LAWN !! RIGHT NOW !!’;
  3. }
  4. add_filter( ‘login_errors’, ‘no_wordpress_errors’ );

In this way, WordPress no longer outputs valid hints that can reduce the likelihood that the site will be compromised.

4. Keep the WordPress login status longer
If you are using WiFi or other wireless network, or use the public computer when the Internet, log on any one site, we must remember to withdraw in time. However, if you at home or company, use their own computer, after a while will be kicked out by WordPress, need to re-login, then it is also very annoying. At this time, you can try this technique to extend the retention time of WordPress login status. Likewise, copy the code into the funcitons.php file or in a site-specific plugin:

  1. add_filter( ‘auth_cookie_expiration’, ‘stay_logged_in_for_1_year’ );
  2. function stay_logged_in_for_1_year( $expire ) {
  3.   return 31556926; // 1 year in seconds
  4. }

By default, if you select the “Remember Me” option when you log in to WordPress, WordPress will remain logged in for 2 weeks. In the above code, we set it to 1 year.

5. Replace “Hello” with “Login as …” in the WordPress toolbar
If you think WordPress at the top of the menu toolbar, the default “Hello” is not suitable for formal occasions, or you want to change a welcome message, please copy the following code to functions.php file, or on the website dedicated plug-in:

  1. function replace_howdy( $wp_admin_bar ) {
  2.     $my_account=$wp_admin_bar-&gt;get_node(‘my-account’);
  3.     $newtitle = str_replace( ‘Howdy,’, ‘Logged in as‘, $my_account-&gt;title );
  4.     $wp_admin_bar-&gt;add_node( array(
  5.         ‘id’ =&gt; ‘my-account’,
  6.         ‘title’ =&gt; $newtitle,
  7.     ) );
  8. }
  9. add_filter( ‘admin_bar_menu’, ‘replace_howdy’,25 );

In the third line of the above code, the $ newtitle parameter can set the desired greeting. If you want to use Chinese here, please remember to save the file as UTF8 no BOM format.

6. Modify WordPress to manage the background footer text
Brand promotion is to convey information and consistent. So if you create a website for your customers, what you want to do for yourself makes your customers happy and very important to them. Therefore, in addition to changing the login page and management background of the upper left corner of the Logo, you can also manage the background part of the background to add the customer’s slogan (corporate values, vision, etc.) or other interesting text.
Cool! Place the following code in the funcitons.php file, or within the site-specific plugin:

  1. function remove_footer_admin () {
  2.   echo &quot;Your own text&quot;;
  3. }
  4. add_filter(‘admin_footer_text’, ‘remove_footer_admin’);

Now, you can add some here to give people a deep impression on the text, or quote some inspirational, connotation of the text, on the echo that line in the double quotation marks on it


7. Add short code to the gadget (pendant)
Short code (shorcode, also translated as “short code”, “short code”, etc.) super useful, because they only need a pair of square brackets, you can replace the original very long code snippet. By default, WordPress Widget (pendant, gadget) does not support short code, can only speak short code as ordinary word processing. However, you can simply use the following code in the functions.php file for the theme you are using, or within the site-specific plugin, you can use the short code in the gadget:

  1. define(‘widget_text’, ‘do_shortcode’);

In this way, you can use short code in Widgets (gadgets).


How to reset the WordPress database

There are always WordPress novice in the theme of the cat’s QQ user group asked this question: how to clear WordPress website data ah? How to restore the wordpress website to the initial state? The simpler rude solution is to empty the database and reinstall it. But today the theme cat to give you recommend a more simple way.
Even skilled use of WordPrss master, there will be such a demand: for example, sometimes need to test the new wordpress theme or plug-in, to delete all the contents of the wordpress site; or want to empty the site content, re-do a new blog.
Before we encounter this problem, we will delete the existing installation (mainly empty or delete the database, etc.); then re-install WordPress. But this is still a bit cumbersome, especially for users who are not familiar with the operation of the database. Now, the theme cat gives you a wordpress plugin that lets you easily reset the WordPress site.

WordPress Database Reset plugin
WordPress Database Reset, meaning “WordPress database reset”, is a free plug-in from WordPress official plug-in directory, you can restore the WordPress database to the default state. Since the various settings of the WordPress site are stored in the database, this also means that all content of the site will be erased and the site will be restored to the initial installation state.
The wordpress plugin is very easy to use, install and enable the plug-in, in the management of the background sidebar management options, find the “Tools (Tools) -” [database reset (Database Reset)].

Here, you can choose to empty a single table (table), such as delete all comments, delete all pages, etc .; you can also choose to empty all the tables.
Next, enter the plugin generated string, in this case s42Uz, and then click the [Reset Database] button. Then, the plugin will revert to WordPress initial settings and bring you back to the admin background home page.
The plugin will not delete or change your files, such as your uploaded images. It only removes custom options and content, including pages, articles and comments, and so on. However, if you want to reset the important site, in order to prevent mistakes, be sure to do a good job backup.

WordPress development tutorial: the original ecology of the wordpress ajax

Recently small V (site friends) in the development of an adaptive wordpress blog theme, the wordpress theme of a large number of data display and submission are used ajax technology, so small V specially written a tutorial record, to facilitate other wordpress developers do wordpress ajax application development time to do reference. If some small partners do not know what is ajax, please Baidu Baidu ~ ~, gossip is not to say, the tutorial began.
Many developers in the write plug-in like the following way to achieve ajax:

  1. require_once( ‘../../../../wp-config.php’ );

Even the Baidu webmaster platform official development of the wordpress structured data submitted plug-in is also the realization of ajax, which is a very irrational wording, because once the user set the directory is different, the relative path will be invalid. And if you Your plugin is using object-oriented writing, you will not be able to directly use some variables and private methods. The biggest drawback is that will lead to the entire WordPress framework to reload again, seriously affecting the efficiency of the site.
In fact, wordpress in order to facilitate the development of developers with ajax function plug-in theme has been pre-defined ajax method, we only need to use the official reservation method to use just fine. In the development of wordpress ajax you first understand that, whether it is the background or foreground any Ajax requests are in admin-ajax.php deal, send a request to admin-ajax.php, there is a required parameter is $ _REQUEST [‘action’] because admin-ajax.php needs to trigger different hooks depending on whether the user is logged in.

  1. if ( is_user_logged_in() ) {
  2.     /**
  3.      * Fires authenticated AJAX actions for logged-in users.
  4.      *
  5.      * The dynamic portion of the hook name, `$_REQUEST[‘action’]`,
  6.      * refers to the name of the AJAX action callback being fired.
  7.      *
  8.      * @since 2.1.0
  9.      */
  10.     do_action( ‘wp_ajax_’ . $_REQUEST[‘action’] );
  11. else {
  12.     /**
  13.      * Fires non-authenticated AJAX actions for logged-out users.
  14.      *
  15.      * The dynamic portion of the hook name, `$_REQUEST[‘action’]`,
  16.      * refers to the name of the AJAX action callback being fired.
  17.      *
  18.      * @since 2.8.0
  19.      */
  20.     do_action( ‘wp_ajax_nopriv_’ . $_REQUEST[‘action’] );
  21. }

The above code from the wordpress system file admin-ajax.php, from the above code we can see that we want to initiate a request first to know whether this request is initiated in the login state? Different state trigger hook is not the same, the following is a theme in the use of jquery achieve ajax example code:

  1. add_action (‘wp_head’, ‘v7v3AjaxScript’);
    function v7v3AjaxScript () {
    print ‘<script> var v7v3_ajaxurl = “‘. admin_url (‘admin-ajax.php’). ‘”‘. “; </ script> n”;
    print “<script>
    $ (docunment) .ready (function () {
    $ .ajax ({
    url: v7v3_ajaxurl,
    data: {
    action: ‘is_login’
    type: ‘post’,
    cache: false,
    success: function (data) {
    alert (data);
    </ scrip> “;

    add_action (‘wp_ajax_nopriv_is_login’, ‘v7v3_ajax_not_login’);
    add_action (‘wp_ajax_is_login’, ‘v7v3_ajax_is_login’);

    function v7v3_ajax_is_login () {
    global $ current_user;
    get_currentuserinfo ();
    printf (‘Login User Hello:% s!’, $ current_user-> display_name);
    / / Die before the end of the die or exit is very important, we must add.

    function v7v3_ajax_not_login () {
    print ‘Dear Visitors Hello! ‘;
    / / Die before the end of the die or exit is very important, we must add.

In the development of wordpress ajax application is the most important point before the end of the function must be added die or exit, if not add the wordpress framework will be reloaded again.