| Server IP : 39.106.62.82 / Your IP : 216.73.217.128 Web Server : nginx/1.14.1 System : Linux iz2ze1m0zmp2dk5c3j5ap5z 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /webdata/gohomesh.com/wp-content/themes/gongheng/ |
Upload File : |
<?php /* Template Name: page-data */ ?>
<?php
$post = $_POST;
$page_num = 10;
if($post['activepage'] == 1){$offset = 0;}else{$offset = ($post['activepage']-1)*$page_num;}
$price = $post['price'] ? $post['price'] : '';
$area = $post['area'] ? $post['area'] : '';
$time = $post['time'] ? $post['time'] : '';
$search = $post['search'] ? $post['search'] : '';
unset($post['activepage']);
unset($post['price']);
unset($post['area']);
unset($post['time']);
unset($post['search']);
$arr = array();
foreach ($post as $value) {
$arr[] = $value;
}
if($arr){
$arg = array(
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => $arr,
'include_children' => true,
'operator' => 'AND'
),
),
'meta_query' => array(
'relation' => 'AND',
'price_clause' => array(
'key' => 'price',
'type' => 'numeric',
),
'm_clause' => array(
'key' => 'm',
'type' => 'numeric',
),
),
'posts_per_page' => $page_num,
'offset' => $offset
);
}else if($search){
$arg = array(
'post_type' => 'post',
'posts_per_page' => $page_num,
'offset' => $offset,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'title',
'value' => $search,
'compare' => 'LIKE'
),
array(
'key' => 'address',
'value' => $search,
'compare' => 'LIKE'
)
),
);
// $arg = array(
// 'post_type' => 'post',
// 'posts_per_page' => $page_num,
// 'offset' => $offset,
// 's' => $search
// );
}else{
$arg = array(
'post_type' => 'post',
'posts_per_page' => $page_num,
'offset' => $offset,
'meta_query' => array(
'relation' => 'AND',
'price_clause' => array(
'key' => 'price',
'type' => 'numeric',
),
'm_clause' => array(
'key' => 'm',
'type' => 'numeric',
),
),
);
}
if($price == 'prev'){
$arg['orderby']['price_clause'] = 'ASC';
}
if($price == 'next'){
$arg['orderby']['price_clause'] = 'DESC';
}
if($price == ''){
if($arg['orderby']['price_clause']) unset($arg['orderby']['price_clause']);
}
if($area == 'prev'){
$arg['orderby']['m_clause'] = 'ASC';
}
if($area == 'next'){
$arg['orderby']['m_clause'] = 'DESC';
}
if($area == ''){
if($arg['orderby']['m_clause']) unset($arg['orderby']['m_clause']);
}
if($time == 'prev'){
$arg['orderby']['modified'] = 'ASC';
}
if($time == 'next'){
$arg['orderby']['modified'] = 'DESC';
}
if($time == ''){
if($arg['orderby']['modified']) unset($arg['orderby']['modified']);
}
// var_dump($arg);
$new = new WP_Query($arg);
$arrs = array();
if($new->have_posts()) : while($new->have_posts()) : $new->the_post();
// if ($search) {
// if(stristr(get_the_title(),$search)){
// $arrs['content'][] = array(
// 'title' => get_the_title(),
// 'price' => replace_text_wps(get_field('price')),
// 'price2' => replace_text_wps(get_field('price2')),
// 'img' => replace_text_wps(get_field('img')),
// 'link' => get_permalink(),
// 'title2' => replace_text_wps(get_field('title')),
// 'address' => replace_text_wps(get_field('address')),
// 'model' => replace_text_wps(get_field('model')),
// 'nature' => replace_text_wps(get_field('nature')),
// 'm' => replace_text_wps(get_field('m')),
// );
// }
// }else{
// }
$arrs['found_posts'] = $new->found_posts;
$arrs['max_num_pages'] = $new->max_num_pages ? $new->max_num_pages : 1;
$arrs['content'][] = array(
'title' => get_the_title(),
'price' => replace_text_wps(get_field('price')),
'price2' => replace_text_wps(get_field('price2')),
'img' => replace_text_wps(get_field('img')),
'link' => get_permalink(),
'title2' => replace_text_wps(get_field('title')),
'address' => replace_text_wps(get_field('address')),
'model' => replace_text_wps(get_field('model')),
'nature' => replace_text_wps(get_field('nature')),
'm' => replace_text_wps(get_field('m')),
);
endwhile;endif;wp_reset_query();
// if($search){
// $arrs['found_posts'] = count($arrs['content']);
// $arrs['max_num_pages'] = ceil(count($arrs['content'])/$page_num);
// }
wp_send_json($arrs);