I created some custom post type [by code not plugin] and I want to use search filter ajax for these post types. here are my custom post types :
<?php
function add_custom_meta_box() {
add_meta_box(
'custom_meta_box',
'اطلاعات تور',
'show_custom_meta_box',
'post',
'normal',
'high');
}
add_action('add_meta_boxes', 'add_custom_meta_box');
// Field Array
$prefix = 'dm_';
$custom_meta_fields = array(
array(
'label'=> 'شروع قیمت از',
'desc' => 'حداقل قیمت هر تور را به تومان وارد کنید',
'id' => $prefix.'lowcost',
'type' => 'text'
),
array(
'label'=> 'مبدا',
'desc' => 'شهر مبدا تور را وارد کنید',
'id' => $prefix.'mabda',
'type' => 'text'
),
array(
'label'=> 'مقصد',
'desc' => 'شهر مقصد را وارد کتید',
'id' => $prefix.'maghsad',
'type' => 'text'
),
array(
'label'=> 'اقامت',
'desc' => 'تعداد شب های اقامت را مشخص کنید',
'id' => $prefix.'eghamat',
'type' => 'text'
),
array(
'label'=> 'هتل چند ستاره',
'desc' => 'از بین عدد 1 تا 5 یک عدد را بنویسید',
'id' => $prefix.'starrating',
'type' => 'text'
),
);
function show_custom_meta_box() {
global $custom_meta_fields, $post;
echo '<input type="hidden" name="custom_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';
echo '<table class="form-table">';
foreach ($custom_meta_fields as $field) {
$meta = get_post_meta($post->ID, $field['id'], true);
echo '<tr>
<th><label for="'.$field['id'].'">'.$field['label'].'</label></th>
<td>';
switch($field['type']) {
case 'text':
echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="55" />
<br /><span class="description">'.$field['desc'].'</span>';
break;
// checkbox
case 'checkbox':
echo '<input type="checkbox" name="'.$field['id'].'" id="'.$field['id'].'" ',$meta ? ' checked="checked"' : '','/>
<label for="'.$field['id'].'">'.$field['desc'].'</label>';
break;
}
echo '</td></tr>';
}
echo '</table>';
}
function save_custom_meta($post_id) {
global $custom_meta_fields;
if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__)))
return $post_id;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
if ('page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id))
return $post_id;
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
foreach ($custom_meta_fields as $field) {
$old = get_post_meta($post_id, $field['id'], true);
$new = $_POST[$field['id']];
if ($new && $new != $old) {
update_post_meta($post_id, $field['id'], $new);
} elseif ('' == $new && $old) {
delete_post_meta($post_id, $field['id'], $old);
}
}
}
add_action('save_post', 'save_custom_meta');
?>
So I want use filter searching for these field post type ids : locost - eghamat - mabda - maghsad - starrating