Cheatsheet: WordPress

Cheatsheet: WordPress

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() )

Example

<?php 
	$to= get_option('admin_email_to') ;
	$subject="Get A Quote";
	$message="Name:".$_POST['message_name']."<br>"."Email:".$_POST['message_email']."<br>"."Mobile:".$_POST['message_mobile'];
	$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 )
get_user_meta( int $user_id, string $key = '', bool $single = false )

 

Leave A Comment

Avada Programmer

Hello! We are a group of skilled developers and programmers.

Hello! We are a group of skilled developers and programmers.

We have experience in working with different platforms, systems, and devices to create products that are compatible and accessible.