"1001" amazing WordPress tricks you need to know

Just like the title of the post above I said.

In this article, I will show you all the WordPress tricks.

Which Hawk finds the best and most useful for any WordPress website.

You can freely apply it to your website, or play around to learn WordPress.

Let’s get started now…

thu-thuat-wordpress

1. Change the default login URL

This is one of the tricks, I encourage you to do it immediately.

It’s quite simple but helps you avoid spam or brute force attack.

Everyone knows, by default the admin login path will have the form: dieuhau/wp-admin.

Even now, there are many websites with default login url.

The next worst thing is that User and Password are also very easy to figure out

  • Admin
  • 123456789
  • admin
  • iloveyou
  • 12345678
  • Password

And hackers simply create a scanning tool, and maybe your website is among them.

So changing the login URL and creating a strong password is essential.

The simplest way is that you can use plugins like:

They all have the feature to change the login path easily.

2. Change the interface of the Login page

If you are bored with the default interface when logging in.

You can completely customize it to your liking in the following ways.

Go to your current theme folder wp-content/themes/ten-cua-theme/.

Create a folder named "Login", then create a file in that folder custom-login-styles.css.

Next, go to the function.php file and add the code below:


  function my_custom_login() {
  echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('stylesheet_directory') . '/login/custom-login-styles.css" />';
  }
  add_action('login_head', 'my_custom_login');
  

Okie now you just need to customize the CSS to the file custom-login-style.css is to be.

To change the logo you can use the following CSS, remember to change the values.

And the logo will be 80px by 80px.

Add title to appear with logo

function my_login_logo_url_title() {
      return 'Your Site Name and Info';
  }
  add_filter( 'login_headertitle', 'my_login_logo_url_title' );

Change the recording path by clicking on the logo

function my_login_logo_url() {
      return "https://www.example.com";
  }
  add_filter( 'login_headerurl', 'my_login_logo_url' );

3. Disable post revisions

Post revision is one of the great features of WordPress.

However, some people will not like it very much, because it burdens your database.

It’s very simple, you just need to add the following code to the file wp-config.php.

define('AUTOSAVE_INTERVAL', 120 ); // seconds
  define('WP_POST_REVISIONS', false );

This code will help you completely disable Post Revisions function.

And increased auto save time from 60 to 120s.

4. Delete existing post revisions

Above, I have instructed to disable the post revision function.

So how to delete all existing post revisions in WordPress.

Run the SQL statement from PHPMyAdmin:

DELETE FROM wp_posts WHERE post_type="revision";

5. Tạo child theme

If you often edit the code on the theme.

Definitely using a child theme is essential, it helps you to update without losing old customizations.

It’s very simple, just create a folder named your-child-theme.

In which create 1 css file as follows:

/*
  Theme Name: Child Theme Name
  Template: parenttheme
  */
  @import url("../parenttheme/style.css");

To learn more about Child Theme you can refer to the article:

6. Tạo custom page template trong WordPress

By default, a website will display the lastest (latest post) on the homepage.

You can change it, and choose any page as homepage.

Just enter Setting » Reading

Or if you don’t like it, you can create your own homepage template.

Create a file named custom-homepage-template.php.

And add the following code, remember to save it.


  <?php /* Template Name: Custom Homepage */ ?>
  

Then upload the custom-homepage-template.php file to the wp-content/themes/ten-theme/ folder.

Go back to create a new page you will see the name Custom Home in the template section.

Note that this page is completely white, you can customize it yourself.

Or use the page builder to drag and drop if you don’t know the code.

7. Allow users to subscribe to comments

By default, users will not be able to know that you have replied to their comment.

So how do users know you just replied to their comment?

That is to allow users to track their comments.

When you respond, an email notification will be sent to the user

Simply install the plugin Subscribe to Comment Reload.

Then you just need to Active and Setting for the plugin.

8. Install Google Analytics for the website

Of course, every website needs to have Google Analytics installed.

Keeping track of parameters is essential for future plans.

Now in addition to installing Google Analytics directly.

You can already use Google Tag Manager to install and combine all tags in one place.

Easier to manage, easier to change tags.

9. Customize Gravatar Image

By default, WordPress will use Gravatar to display the avatar for the user profile.

If that user doesn’t have a Gravatar, then WP will use the default images bundled as "Mystery Permission".

You can easily see them in the comments (mostly few Gravatar users).

If you want to choose your own branded images.

Then it can be changed in the following way:

First, upload those images to the media.

Then add the following code to the function.php file.


  add_filter( 'avatar_defaults', 'dieuhau_new_gravatar' );
  function dieuhau_new_gravatar ($avatar_defaults) {
  $myavatar="http://example.com/wp-content/uploads/2017/01/dieuhau-default-gravatar.png";
  $avatar_defaults[$myavatar] = "Default Gravatar";
  return $avatar_defaults;
  }
  

10. Use the Inspect tool to edit the interface

On the browser we use every day, there is a very nice tool for Web Developer.

That is Inspect, all browsers are available from FireFox, Chrome…

As you all know on the website, each component will be numbered by the Developer ID or name.

For ease of editing as well as design later.

So are the CSSs they belong to different classes.

Want to know which CSS class the element you want to edit belongs to.

Simply right-click on the element and select Inspector.

Inspect-Tool

Like here I see a change font-size of H1 from 30px to 40px

change-font-size

Immediately the left side will change accordingly for your ease of use.

Like the preview feature on many tools.

You can apply the same to many different elements on the website.

11. Add Custom CSS on WordPress Themes

Above you already know how to use Inspect to customize fonts, colors, alignment…

So how to add these css to the theme you are using.

Very simple you just go to the menu Appearance » Customize

customize-wordpress

In the last line you choose Additional CSS

additional-css

For example, here I change the font to roboto and the red color of the H2 . tag

custom-css-example

12. Changing the Thumbnail when sharing on the network will meet

When sharing articles on facebook it will automatically get the image in your post.

Normally it will take the feature image as well, but you can change or default to another image.

You can use the Yoast SEO plugin or Rank Math to change the thumbnail image when sharing on facebook.

social-thumbnail

You can choose an image, fill in the title and description to suit your content.

And if you want to leave the default, you can go to Social in the Yoast Menu

Yoast-Social-Tab

Guys, stay calm every day, I will update the next trick 😀

0 Comments

(code-box)