By default, WordPress comes with default functions written for you and ready to be used anytime you like and anywhere in the website.
What is function?
Well, a function is a reusable block of code designed to perform a specific task. When defining a function, you specify its name, parameters, and code body. To use the function, you simply call or invoke it, passing any required arguments. The function then executes its code block and can return a value back to the calling code. This modular approach promotes code reuse and organization.
In short, you define a function in one area of your code to do some work, then you can call that function anywhere in the website to apply the work it can do by passing values. Simple example is as shown below.
<?php function computer_specs ($model, $screensize, $weight){
echo "<p>This computer is $model with screen size $screensize and weight is $weight</p>";
}
?>
This is how functions are defined in PHP so that it can be called later on
<?php
computer_specs ("Model 1", "40 inch", "5g");
computer_specs ("Model 2", "42 inch", "2g");
?>
Upon calling, it will print two line of sentences as
This computer is Model 1 with screen size 40 inch and weight is 5g
This computer is Model 2 with screen size 42 inch and weight is 2g
This how you call a function by it’s name by assigning values to each variable it accepts.
WordPress pre-defined functions
WordPress predefined functions are built-in functions provided by the WordPress core, designed to perform various tasks within WordPress sites. These functions handle common functionalities such as displaying content, querying the database, handling user authentication, and managing site settings. By utilizing these predefined functions, developers can efficiently customize and extend WordPress websites without needing to write extensive custom code, thereby simplifying development and ensuring compatibility with future WordPress updates.
In custom coding, as you have to define a function in somewhere in the code to be able to call it and pass values to it, WordPress comes with predefined functions that you can call anywhere in your website. Those functions are defined by WordPress it self so that it can be call with arguments.
How to get site information on wordpress?
You can get site info or call any function in WordPress, by calling functions which are defined in official WordPress website by passing arguments that are specified.

— Thankyou for Reading —





