0

what is the use of function.php in wordpress?

   <?php 
function amazing_script_equeue(){wp_enqueue_style('customstyle',get_template_directory_uri().'/css/awsomew.css',array( ),'1.0.0','all');}
add_action('wp_enqueue_scripts','amazing_script_equeue');

what does the above code do when the page loads?

2 Answers 2

1

The codex puts it nicely:

One way to change the default behaviors of WordPress is using a file named functions.php. It goes in your Theme's folder.

The functions file behaves like a WordPress Plugin, adding features and functionality to a WordPress site. You can use it to call functions, both PHP and built-in WordPress, and to define your own functions. You can produce the same results by adding code to a WordPress Plugin or through the WordPress Theme functions file.

The code in question is a function that is being called at runtime, which is pulling a file called /css/awsomew.css into the themes frontend. This file is located at ...wp-content/your-theme-name/css/awsomew.css. For more information on the wp_enqueue_style() function, see the codex as well.

Sign up to request clarification or add additional context in comments.

Comments

0

Theme functions.php behaves like a plugin that runs inside the theme file, almost all code you'll find on plugins will also run when added on functions.php file,

the above functions you have provided will add this stylesheet below inside your head tag,

<link rel='stylesheet' id='customstyle' href='yoursite.com/wp-content/themes/themename/css/awsomew.css?ver=1.0.0' type='text/css' media='all' />

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.