Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Actually i have created a custom post type and fetch the data from "Advanced Custom Fields" plugin after then connect to a custom search-form to search only the post data.It works good. But now i want to search post data from field name (label) or any other related keyword.

This is code that works when i search post name but does not work when search field name and other related key word.

<?php 
echo 'this is search='; 
echo $s;
$args = array(
    'post_type'=> 'beauty_salon',
   's' =>$s,
    'the_field'=>$treatments
);
query_posts($args);
?>
<?php if ( have_posts() ) : ?>
<hr class="boder">
<div class="arc_content" id="results">
<ul>                
<?php while ( have_posts() ) : the_post(); ?>
<li class="clearfix">
<a href="<?php the_permalink(); ?>" ><h1><?php  the_title(); ?></h1></a>
<?php $attachment_id = get_field('beauty_salon_image_1');
$size = 'custom_archive_thumbnail';  //(thumbnail, medium, large, full or custom size)
$image = wp_get_attachment_image_src( $attachment_id, $size );
$attachment = get_post( get_field('beauty_salon_image_1') );
$alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
?>
<a href="<?php the_permalink(); ?>" ><img src="<?php echo $image[0]; ?>" alt="<?php echo $alt; ?>"/></a>
<div class="arc_inner">
<h6>Treatments:<strong><?php echo the_field('treatments') ?></strong></h6>
<h6>Bookings 1:<strong><?php echo the_field('bookings_1'); ?></strong></h6>
<h6>Bookings 2:<strong><?php echo the_field('bookings_2'); ?></strong></h6>
<h6>Address:<strong><?php echo the_field('address'); ?></strong></h6>
</div>
</li>
<?php endwhile; ?>
</ul>
</div>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>

<!-- if end -->
<?php endif; ?>            

//one template above
 And i used code for search form given below.
<form id="searchform-ajax" action="<?php bloginfo('home'); ?>/" method="get">
<input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s"  class="txt" />
<input type="hidden" name="post_type" value="beauty_salon"  />
<input id="searchsubmit" class="ser-icon" type="submit" value="Search" />
</form>
share|improve this question
    
Please use code tag to place code. You have a button for it in your tools of editor. –  Imran Jul 2 '13 at 10:13

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.