WP(wordpress),being an absolute platform for open source blogging is loved by millions. It has been recently reported that more than one million websites are presently running on WordPress platform. Your WordPress site can surely stand a difference, if and all you are clear with some basic functions used in WordPress. Here you can find out some basic function which could purely favor WordPress Beginners
WP(wordpress) Function List:
Login / Logout Function
wp_register(); – This tag displays either the “Site Admin” link if the user is logged in or “Register” link if the user is not logged in.
wp_loginout(); – Displays a login link if a user has not yet logged in and if a user is already logged in, displays a logout link. An optional, redirect argument can be used to redirect the user upon login or logout.
is_user_logged_in(); – Checks if the current visitor is logged in. This is a boolean function, which means it returns either True or False.
To include those files in your current theme’s directory, all you have to do is, use the get_sidebar(); function but add parameters to each function call to tell WordPress which sidebar you want to include and where it needs to be included.
For more understanding:
To include the file “sidebar-right.php”, use:
To include the file “sidebar-left.php”, use:
get_header(); – Includes the header.php from the current template directory. If any thing is needed to be placed in the header, it can be written in header.php and this function can be called.
get_footer(); – Includes the footer.php template file from your current theme’s directory. Any thing needed to be placed in the footer (For eg., Copyrights,Powered by) can be written in footer.php and then this function can be called.
get_sidebar(); – Includes the sidebar.php template file from your current theme’s directory. We can also include multiple sidebars by specifying the parameters. Let’s say we’ve two sidebars, right and left, and we’ll name the files
wp_create_user( $username, $password, $email ); – This function allows you to insert a new user into the WordPress database. If successful, this function returns the user ID of the created user. In case of failure (username or email already exists) the function returns an error object,
wp_delete_user($id); -This function is Used to delete User. For eg., wp_delete_user(56); – This will delete the entire record of user id ’56′
wp_insert_user($userdata); -This function inserts a user data into the database when passing an array of user data.
For example, I have taken the array of user details for logging in.
$userdata = array(
‘user_login’ => ‘login’,
‘user_email’ => ‘[email protected]’,
‘user_pass’ => wp_hash_password(’12345′),
‘user_url’ => ‘http://ikodes.com’,
‘display_name’ => ‘ikodes name’,
‘description’ => ”,
‘role’ => ‘author’
Now to insert the data, let’s use, wp_insert_user($userdata);
Plugin Action Functions
add_action($tag,$function_to_add,$priority,$accepted_args); – Hook a functions on to a specific action or method to call the function. Actions (Method) are trigger (call) when the WP (WordPress) core file calls do_action().
do_action($tag,$arg); -Executes a hook created by add_action.
remove_action($tag,$function_to_remove,$priority,$accepted_args ); – Removes a function attached to a specified action hook.
has_action( $tag, $function_to_check ); – Check if any action has been registered for a hook.
Hope you’d gone a valid info on the basic functions used for WP(wordpress).