Last active
December 11, 2015 14:09
-
-
Save joshmoto/4612377 to your computer and use it in GitHub Desktop.
This is my php file which will load in via ajax when my form is submitted...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('WP_USE_THEMES', false); | |
require ('/home/sites/mysite.co.uk/www/wp/wp-load.php'); | |
$ajaxCounty = $_GET['varCounty']; | |
$ajaxTown = $_GET['varTown']; | |
$dealerResults = new WP_Query(array( | |
'post_type' => 'dealer', | |
'meta_query' => array( | |
array( | |
'key' => 'dealer_county', | |
'value' => $ajaxCounty, | |
'compare' => '=' | |
), | |
array( | |
'key' => 'dealer_town', | |
'value' => $ajaxTown, | |
'compare' => '=' | |
) | |
) | |
)); | |
?> | |
<?php if ($dealerResults->have_posts()) : ?> | |
<div class="dealer-wrapper"> | |
<?php while ($dealerResults->have_posts()) : $dealerResults->the_post(); ?> | |
<h1><?php the_title ?></h1> | |
<ul> | |
<?php | |
$address1 = get_post_meta($post->ID, 'dealer_address_1', true); | |
if($address1) { | |
echo '<li>' . $address1 . </li>'; | |
} | |
$address2 = get_post_meta($post->ID, 'dealer_address_2', true); | |
if($address2) { | |
echo '<li>' . $address2 . </li>'; | |
} | |
$address3 = get_post_meta($post->ID, 'dealer_address_3', true); | |
if($address3) { | |
echo '<li>' . $address3 . </li>'; | |
} | |
$address4 = get_post_meta($post->ID, 'dealer_address_4', true); | |
if($address4) { | |
echo '<li>' . $address4 . </li>'; | |
} | |
$town = get_post_meta($post->ID, 'dealer_town', true); | |
if($town) { | |
echo '<li>' . $town . </li>'; | |
} | |
$county = get_post_meta($post->ID, 'dealer_county', true); | |
if($county) { | |
echo '<li>' . $county . </li>'; | |
} | |
$postcode = get_post_meta($post->ID, 'dealer_postcode', true); | |
if($postcode) { | |
echo '<li>' . $postcode . </li>'; | |
} | |
?> | |
</ul> | |
<?php endwhile; ?> | |
</div> | |
<?php unset($dealerResults); endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment