Forming a pop-up window for a portfolio - a lesson 28

Let's continue developing our portfolio and in this tutorial I found a nice popup script, let's try to use it. The script is called Responsive Lightbox Plugin.

To use the script, you must first connect its styles in the site header and then you can connect the script itself to the site footer. See below for more details on how this is done..

Download the script from storage github. An example of the operation of the future pop-up window can be viewed at official site of the script.

Uploading the script to a folder wp-content/themes/my_theme_tmp/js/responsive-lightbox-master/.

Next, we need to connect the script and for its correct connection, we can use the already familiar file custom-header-script.php, it is located at wp-content/themes/my_theme_tmp/functions/custom-header-script.php.

We connect the script and styles to the existing code of the function my_scripts_method

The script is connected using the code:

Full function listing my_scripts_method:

Include styles below in the function.

Full function listing add_my_stylesheet:

After connecting the script and styles, we can look at the result. If everything was done right, it to the pages sitemame/portfolio/ the connected script will appear in the code, and also a new style file.

Style File jquery.lightbox.min.css

jquery.lightbox.js script file

After a successful connection, you must add custom image sizes, fix portfolio template in file archive-my_works.php and specify when clicking on which elements the image will be displayed in large format, in a popup window.

1. Let's go to functions.php and find the code.

Complement the code with a new image size for the portfolio page:

2. Let's go to the template archive-my_works.php and find the code in it:

<img src=”‘.$thymbUrl.'” alt=”” />

You need to change the code to output the correct image size.

If done right, then in the portfolio section, when clicked, the picture will open in a new window.

Attention, there may be a problem and the output of the correct size of the thumbnail, but it's easy to solve.

If your image is not resized as expected, then most likely you need to recreate the portfolio thumbnails using one of the plugins Regenerate Thumbnails or Force Regenerate Thumbnails. After launching plugin activation, run it and be sure to wait for it to finish.

Now that everything is working, you can modify the display of images in a pop-up window. To display a pop-up window, you must correctly register the element, when you click on which the image will appear on top.

Adding code to the footer.php file, as below.

From the above it can be seen, that images will appear in a pop-up window in cases where the tag contains the rel= attribute”lightbox”. Let's make it so that in all the pictures that link to their larger version, this attribute appears. To do this, go to the functions.php file and add the special filter code to it:

After all the manipulations, I got this gallery.

создание портфолио wrdpress

Theme files from this tutorial

zip wordpress theme archive


Buy WordPress hosting
WordPress tutor
Online tutoring services. List of courses I teach
  • Basic web design course;
  • Site layout;
  • General course on CMS WordPress and continuation of the course on template development;
  • Website development in PHP.
Read more on the page WordPress tutor
*/

Nikolaenko Maxim

Director of web studies ProGrafika. I am developing, website design and promotion. Always glad to new blog readers and good clients.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Templates for WordPress
The best hosting in Ukraine
Stable hosting for Drupal