WordPress: Important Functions

WordPress: Important Functions

April 7, 2019

Many of the core WordPress functions are useful to Plugin and Theme developments.

1. wp_mail ()

Sends an email, similar to PHP’s mail function.

wp_mail( string|array $to, string $subject, string $message, string|array $headers = '', string|array $attachments = array() )


	$to= get_option('admin_email_to') ;
	$subject="Get A Quote";
	$headers = array('Content-Type: text/html; charset=UTF-8' , 'From: Name of sender <sender@wp.com>' , 'Bcc: sender2@wp.com');

	$to_customer = $_POST['message_email'];
	$subject_customer ="ABC";
	$message_customer ="Thanks For Connecting With Us! Our support team will contacts you soon.";
	$headers_customer = array('Content-Type: text/html; charset=UTF-8' , 'From: ABC <abc@wp.com>');

	if($to == get_option('admin_email_to')){
	wp_mail( $to, $subject, $message,$headers);	

	if($to_customer == $_POST['message_email']){
	wp_mail( $to_customer, $subject_customer, $message_customer,$headers_customer);	

2. bloginfo()

Displays information about the current site.

3. get_post_meta()

Retrieves a post meta field for the given post ID.

get_post_meta( int $post_id, string $key = ”, bool $single = false )

Leave A Comment