Fix single agency properties

This commit is contained in:
Hoang Huu
2020-03-23 11:13:53 +07:00
parent 9245035bda
commit 73fb75c3fd
7 changed files with 132 additions and 70 deletions

View File

@@ -227,36 +227,36 @@ function opalestate_toggle_featured_property() {
/**
* load more properties by agency
*/
add_action( 'wp_ajax_get_agency_property', 'opalestate_load_more_agency_property' );
add_action( 'wp_ajax_nopriv_get_agency_property', 'opalestate_load_more_agency_property' );
function opalestate_load_more_agency_property() {
$post = [
'post_id' => 0,
'paged' => 1,
'user_id' => 13,
'related' => '',
'limit' => apply_filters( 'opalesate_agency_properties_limit', 5 ),
];
$post = array_merge( $post, $_POST );
extract( $post );
$user_id = get_post_meta( absint( $post_id ), OPALESTATE_AGENCY_PREFIX . 'user_id', true );
$query = Opalestate_Query::get_agency_property( absint( $post_id ), absint( $user_id ), absint( $limit ), absint( $paged ) );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col-lg-12 col-md-12 col-sm-12">
<?php echo opalestate_load_template_path( 'content-property-list-v2' ); ?>
</div>
<?php endwhile;
endif;
wp_reset_postdata();
exit;
}
// add_action( 'wp_ajax_get_agency_property', 'opalestate_load_more_agency_property' );
// add_action( 'wp_ajax_nopriv_get_agency_property', 'opalestate_load_more_agency_property' );
//
// function opalestate_load_more_agency_property() {
//
//
// $post = [
// 'post_id' => 0,
// 'paged' => 1,
// 'user_id' => 13,
// 'related' => '',
// 'limit' => apply_filters( 'opalesate_agency_properties_limit', 5 ),
// ];
//
// $post = array_merge( $post, $_POST );
// extract( $post );
//
// $user_id = get_post_meta( absint( $post_id ), OPALESTATE_AGENCY_PREFIX . 'user_id', true );
// $query = Opalestate_Query::get_agency_property( absint( $post_id ), absint( $user_id ), absint( $limit ), absint( $paged ) );
//
// if ( $query->have_posts() ) :
// while ( $query->have_posts() ) : $query->the_post(); ?>
<!-- <div class="col-lg-12 col-md-12 col-sm-12">-->
<!-- --><?php //echo opalestate_load_template_path( 'content-property-list-v2' ); ?>
<!-- </div>-->
<!-- --><?php //endwhile;
// endif;
// wp_reset_postdata();
// exit;
// }
/**
@@ -271,7 +271,7 @@ function opalestate_get_agent_property() {
'paged' => 1,
'id' => 13,
'limit' => apply_filters( 'opalesate_agent_properties_limit', 1 ),
'limit' => apply_filters( 'opalesate_agent_properties_limit', 6 ),
];
$post = array_merge( $post, $_POST );
@@ -280,13 +280,57 @@ function opalestate_get_agent_property() {
set_query_var( 'paged', $post['paged'] );
$query = Opalestate_Query::get_agent_property( null, absint( $post['id'] ), absint( $limit ) );
$paged = absint( $post['paged'] );
if ( $query->have_posts() ) : ?>
<div class="opalestate-rows">
<div class="<?php echo apply_filters( 'opalestate_row_container_class', 'opal-row' ); ?>">
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col-lg-6 col-md-6 col-sm-12">
<?php echo opalestate_load_template_path( 'content-property-grid' ); ?>
</div>
<?php endwhile; ?>
</div>
</div>
<?php if ( $query->max_num_pages > 1 ): ?>
<div class="w-pagination"><?php opalestate_pagination( $query->max_num_pages ); ?></div>
<?php endif; ?>
<?php
endif;
wp_reset_postdata();
exit;
}
/**
* load more properties by agency
*/
add_action( 'wp_ajax_get_agency_property', 'opalestate_get_agency_property' );
add_action( 'wp_ajax_nopriv_get_agency_property', 'opalestate_get_agency_property' );
function opalestate_get_agency_property() {
global $paged;
$post = [
'id' => 0,
'paged' => 1,
'user_id' => 13,
'related' => '',
'limit' => apply_filters( 'opalesate_agency_properties_limit', 5 ),
];
$post = array_merge( $post, $_POST );
extract( $post );
$user_id = get_post_meta( absint( $id ), OPALESTATE_AGENCY_PREFIX . 'user_id', true );
$user_id = $user_id ? $user_id : null;
$query = Opalestate_Query::get_agency_property( absint( $id ), absint( $user_id ), absint( $limit ), absint( $paged ) );
$paged = absint( $post['paged'] );
if ( $query->have_posts() ) : ?>
<div class="opalestate-rows">
<div class="<?php echo apply_filters( 'opalestate_row_container_class', 'row opal-row' ); ?>">
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col-lg-12 col-md-12 col-sm-12">
<?php echo opalestate_load_template_path( 'content-property-list' ); ?>
<?php echo opalestate_load_template_path( 'content-property-list-v2' ); ?>
</div>
<?php endwhile; ?>
</div>