Optimize the loading of WordPress sites. Setting Expires headers

(No Ratings Yet)

The expires Http header tells the browser that after it has downloaded the required file, it does not need to re-download the file for a certain period of time.

Using the expires header allows you to reduce the load on the server, as well as increase the speed of loading pages on your site. This also solves the "Serve static assets with an efficient cache policy" problem in the page load speed check service PageSpeed Insights (apart from third-party files, for example, this will not solve the problem with Google Analytics scripts). Read more

Ajax form for WordPress

(No Ratings Yet)

Using ajax when submitting a form allows you to submit the form without reloading the page. In WordPress, this is quite simple to implement. Let's say we have the following call order form:

<form class="form-container recall-form-validate">
    <div class="form-title"><h2>Order a call</h2></div>
    <div class="form-title">Your name:</div>
    <input class="form-field form-name" type="text"  name="name" /><br />
    <div class="form-title">Enter your phone number:</div>
    <input class="form-field form-tel" type="text"  name="tel" /><br />
    <div id="submit-ajax" class="submit-container">
        <input class="submit-button" type="submit" value="Send"/>

Now we will write a script that handles the event of clicking on the "Send" button:
Read more

Submit multiple files via ajax form in WordPress

(1 votes, average: 5.00 out of 5)

To send multiple files, html will look like this:

<div class="file-upload"> 
          <input type="file" name="mail_file[]" multiple="multiple" onchange="GetFileName();" id="uploaded-file"> 
          <span>Attach files</span> 
<div id="file-name"></div>

Read more

How to add onclick to a link in WordPress

(No Ratings Yet)

If we want to add the "onclick" attribute to the link, then WordPress will remove it when saving the post.

To prevent this from happening, allow the use of this attribute:
Read more

Robots.txt file for WordPress – plugin

(3 votes, average: 5.00 out of 5)


Making the right robots.txt file for WordPress is very important. Thanks to him, search engines will know which pages to show in the search. That is, the search results will be just what you need, without duplicating WordPress pages. Read more

Remove width and heigth attributes from WordPress thumbnails

(No Ratings Yet)

By default, the_post_thumbnail () function displays html post thumbnails in this way:

<img width="400" height="500" src="" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" 
alt="" srcset="" >

In some cases, it is necessary to remove the width and height attributes of the displayed image. To do this, you can use the wp_get_attachment_image_src () function filter: Read more