Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Location Query

Query to find postcode meta in custom post “location”

// WP_Query arguments
$args = array(
	'post_type'              => array( 'location' ),
	'meta_query'             => array(
		array(
			'key'     => 'postcode',
			'value'   => 'your-postcode',
			'compare' => 'LIKE',
			'type'    => 'CHAR',
		),
	),
);

// The Query
$query = new WP_Query( $args );