Home > Blog > Modification of free or paid WordPress themes

Modification of free or paid WordPress themes

You successfully installed a free or paid WordPress theme according to your wishes and started to enter content – but suddenly you notice that something is bothering you: some articles require an additional image to be added in the head section, you do not want links to be underlined but to change colour, your logo is in the bottom section but you would like to add some text underneath… Problem: the author of the free theme does not care about modifications and the author of the paid theme has no time. What to do? In this article, we will show you how to correctly approach modifications of WordPress themes.

The biggest mistake you can make when implementing modifications is to directly change the theme. If you update the modified theme, you lose all modifications and you have to implement them again. If you are thinking about simply not updating the modified theme, please read our article on how to protect your WordPress installation from hacks and you will quickly change your mind. The solution to still be able to update the theme and also use the modification is to use child themes.

How to create a child theme?

In the themes folder wp-content/themes/ you first have to create a subfolder that will contain files of the child theme. For an easier maintenance, it is recommended to name the folder by adding -child to the original theme name (e.g. ideaz-child). In the created folder, you will have to create at least two files: style.css and functions.php.

The file style.css contains appearance modifications – for the theme to be enabled, it also needs to include the head with the key:value pairs (see attached code). Basically, you can change the values to whatever you like, only the Template value should be the name of the parent theme (in our case: ideaz).

/*
    Theme Name: Ideaz child
    Template: ideaz
    Author: Ideaz Web Agency
    Description: Modified Ideaz Web Agency theme.
    Version: 1.0 pre-alpha
*/

The file functions.php contains PHP code for adding style templates of the parent theme and other possible modifications. For correct loading of all the files required, the file has to contain the attached code snippet.

Enako kot v zgornjem primeru morate tudi tukaj spremeniti vrednosti ideaz in ideaz-child v imena map nadrejene in podrejene teme. As described above, here you will also have to change the values ideaz and ideaz-child to the names of corresponding parent and child themes.

<?php
function parent_theme_fixes() {
    wp_enqueue_style( 'ideaz', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'ideaz-child', get_stylesheet_directory_uri() . '/style.css', array( 'ideaz' ));
}
add_action( 'wp_enqueue_scripts', 'parent_theme_fixes' );
?>

Theme activation, adding modification and creating additional templates

If you performed the above steps correctly, the appearance menu should now show the option for activating the child theme. You can click on the preview and if everything is OK, you can activate it. Remember that after activation, you may have to recreate some menus. And now, after covering the easier part, comes the harder part: adding modifications.

Appearance modifications can be entered as CSS code in the style.css file; but be careful not to delete the head mentioned above. Core modification of the parent theme should be entered into the functions.php file; but remember that the functions.php file of the child theme loads before the same file of the parent theme. In both cases, you have to bear in mind that you are retyping the existing code or adding capabilities, which is why you should not copy all the content from the parent theme.

All the other template files (page.php, single.php, front-page.php, itd.) will be copied from the parent theme, which is why it is recommended to copy the file from the parent theme as a basis. You can also create own, specific template files that are not included in the original theme. For this purpose, see the WordPress guide on template hierarchy.

Do you require assistance?

Because of many guides available, adding modifications may seem simple but do not be deceived. Incorrectly written code can collapse the structure of the site or significantly slow down the loading time. An incorrectly inserted semicolon or curly bracket can take hours until you identify the error. Code copied from another source can cause unexpected bugs or safety vulnerability that you may not see, but criminals definitely will. Would you not rather invest the time spent on modifications in selling your product and/or developing new ideas on improving the product?

As a team with several years of experience in the field of WordPress theme development, we can implement any modification fast and transparently, while thoroughly testing the final site (for more details see our workflow). Contact us and we will surely find a way of providing the assistance you require.