WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to query the custom post type by the three fields below. The two select fields and the one text field. The text field is the one that is not working currently.

What is wrong? How can I fix that?

        <form name="search" action="" method="get">

            <label for="city">City:</label>
            <select name="city" style="width:175px;" >
            $cities = mo_baptist_get_meta('street_city');
            if ($cities) {
                foreach ($cities as $city) {
                    echo "<option value=\"" . $city . "\">" . $city . "</option>";
            <label for="association">Association:</label>
            <select name="association" style="width:175px;">
            $associations = mo_baptist_get_meta('association');
            if ($associations) {
                foreach ($associations as $association) {
                    echo "<option value=\"" . $association . "\">" . $association . "</option>";

            <input type="text" name="zipcode" placeholder="Zip Code" value="<?php $zip_code = mo_baptist_get_meta('street_zip'); ?>"

            <input type="submit" value="search" />
        <?php $az = range('a', 'z');


            <col width="300">
            <col width="200">
            <col />
            <col />

            <th><?php _e('Name'); ?></th>
            <th><?php _e('City'); ?></th>
            <th><?php _e('Phone'); ?></th>
            <th><?php _e('Website'); ?></th>

            <?php $zip_code = $_GET['street_zip']; $cities = $_GET['city'];  $associations = $_GET['association']; 
            if ($cities  || $associations  || $zip_code) {
                $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                'post_type'  =>  'church',
                'order'  => 'ASC',
                'orderby'  => 'title',
                'posts_per_page'  => 25,
                'meta_query'  =>  array(
                        'value'  =>  $cities,
                        'value'  =>  $associations,
                        'value'  =>  $zip_code,
            } else {
                'post_type'  =>  'church',
                'order'  => 'ASC',
                'orderby'  => 'title',
                'posts_per_page'  => 25,
                'paged'  =>  $paged
            )); } if (have_posts()): while (have_posts($paged)): the_post(); $church = get_post_custom($post->ID); ?>
                <td><a href="<?php the_permalink(); ?>" id="church-<?php the_ID(); ?>"><?php the_title(); ?></a></td>
                <td><?php echo $church['street_city'][0]; ?></td>
                <td><?php echo $church['phone'][0]; ?></td>
                <td><?php if (!empty($church['website_url'][0])): ?><a href="http://<?php echo $church['website_url'][0]; ?>"><?php _e('Homepage') ?></a><?php endif; ?></td>
            <?php endwhile; endif; ?>

        <div class="search-pagination">

          <?php kriesi_pagination(); ?>


share|improve this question

If what you are trying to do is pre-populate the text input, it looks to me like you need to echo the $zip_code variable you are creating:

<input type="text" name="zipcode" placeholder="Zip Code" value="<?php $zip_code = mo_baptist_get_meta('street_zip'); echo $zip_code ?>" />

other than that, I also noticed that the text input was not closed - I added that in the above example...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.