Home » Internet » Blogging » WordPress » What is functions.php in WordPress and where can you find it

What is functions.php in WordPress and where can you find it

You can find the functions.php file for WordPress can your theme’s folder. For instance, if these days you are using the latest twentytwelve theme, you’re going to find your functions.php file in this folder.

Just as you can change the layout, the look and feel of your WordPress blog or website with style.css, you can also change the functionality of the program by creating functions and saving them in the functions.php file. A good example can be, making your sidebar widget-friendly.

If you’re creating a theme from scratch, it is not going to support widgets. Widgets can be very friendly and convenient because you simply have to drag and drop them in order to avail their features. Without widgets, you may have to create lengthy PHP code within your sidebar file.

In the functions.php you can save the following code:

if ( function_exists(‘register_sidebars’) ) {
register_sidebars(2, array(‘name’=>’sidebar %d’, //for single sidebar use register_sidebar()
‘before_widget’ => ‘<div class=”widget”>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h2>’,
‘after_title’ => ‘</h2>’,

Then you can use the following code in your sidebar to make use of the WordPress widgets:

<div class=”sidebar-right”>
<?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘sidebar 1’) ){?>
<?php echo “No widget!”;} ?>

This is not the only use of the functions.php file. WordPress comes with many hooks. These hooks you can use to change the behavior of the way content appears on your blog. Suppose you want to insert something before the beginning of your blog posts according to a particular criteria. Have a look at this blog post titled 25 extremely useful tricks for the WordPress functions file.