WordPress Theme Modification
WordPress Theme Modification

A WordPress theme is a collection of templates and style sheets that determine the look of your website. WordPress provides a vast number of themes that you can install on your website. Be it be an e-commerce site, a portfolio site or just a blog site, you will get a theme for any kind of website you are building.

Most of the themes provide you with a look and feel that you want for your website. But sometimes you feel like you want to add something more or may be remove some existing theme features just to make it look perfect, and this is when you have to modify the existing theme according to your needs.

Modifying a WordPress theme is not an easy task. You have to be careful so that you do not break the existing theme. So you should follow certain practices to modify the theme without messing up with the existing theme functionality.

You should always start modifying your theme from the theme customizer. Most of the WordPress themes provide you with some basic customization functionality. You can access this customizer from the admin dashboard. Here you can change the name and logo of your site, set the page width, change the footer content, modify the menu, customize buttons, etc. Depending on the theme installed, the customization options available might vary.

If you feel the theme customizer does not provide you with all the options and you need to change the theme files, never ever go and change the original theme files directly. You might loose all your custom changes on a theme upgrade. Its always a good practice to create a child theme and add all the customization code in the child theme. This way you make sure that you do not break the original theme and do not loose your custom changes on theme up-gradation.

Creating a child theme is very easy. You can visit the following link for creating child theme. Child theme will consist of a functions.php and style.css file. All the custom css code will go in the child theme’s style.css file and in the functions.php file you will need to ensure the style.css file of both parent and child theme.

Sometimes you may feel that you need to change particular template file to change the look of a page. First check if you can achieve this by simply adding some css rules, if no then you can simply copy this template file to your child theme directory and override it. Keep in mind that you follow the directory structure while adding the file to your child theme and do not change the template name. This way the theme will use the template file in the child theme to display the page.

Some more advanced way to modify theme would be using hooks. Hooks allow you customize theme by adding or changing the default WordPress output. You can either use action hook or filter hook based on your need. Action hooks are triggered when a particular even occurs. For example, if you want to add some custom text to you footer you can use the wp_footer hook which adds code directly before the closing <body> html tag.

function custom_function_name() {
echo “Your custom text here”;
add_action(‘wp_footer’,’custom_function_name’) will tell WordPress that you want to call custom_function_name function when the wp_footer action is triggered. Inside your custom function you can add the text that you want to display in the footer.

Similarly you can use the filter hook to modify the default content before it is displayed on the browser. Look at the following example.

function custom_excerpt_length( $length ) {
return 20;
add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 );

Using the excerpt_length hook you can change the no of words to display in the excerpt.

Many themes use custom hooks to make the code more extendable. You can make use of these custom hooks to modify the theme.

That’s all, these are some of the ways that you can follow while customizing your theme. Make sure you always create a child theme since it will always be easy for you to switch back to the original theme if your changes break something. Start with the theme customizer, go further and create child theme, add custom styles, override templates and use hooks to customize the theme. Hope this helps you.


Divyani Karekar

Post Comments

* marked fields are mandatory.