WordPress functions are described in the Codex with an individual Function Reference page for each WordPress API function available. These pages explain in detail exactly how a WordPress function works, as shown in Figure 4-2. Bookmark this page for a quick reference on WordPress functions and their capabilities. The official Function Reference is located at http://codex.wordpress.org/Function_Reference.
Think of the Function Reference as an online and expanded version of a function's inline documentation. The reference has a description explaining how the function works and how it is used. The individual parameters are listed along with data types and a description of each.
The most useful section of the Function Reference is the examples toward the bottom. The examples make it very easy to see exactly how to use the function. The get_userdata example is shown here:
echo('Username: ' . $user_info->user_login . "\n"); echo('User level: ' . $user_info->user_level . "\n"); echo('User ID: ' . $user_info->ID . "\n");
This example shows how to load specific user data for user ID 1. The example output is as follows:
User Level: 10
User ID: 1
This is a simple example, but this along with the additional reference information can help you easily learn a new function and how to use it properly in your code.
The final Function Reference topic lists related functions. This can help identify a similar function that may accomplish that task you are working on. For example, the wp_insert_post function lists wp_update_post and wp_delete_post as related functions.
The majority of the WordPress API functions are well documented, but not all functions have a Function Reference page in the Codex. Any function displayed in red on the Function Reference homepage currently has no documentation. This is an ongoing community project so expect all functions to be fully documented in the Codex eventually.
Was this article helpful?