Pagination
unknown
php
2 years ago
5.0 kB
16
Indexable
<?php
$args = array(
'post_type' => 'oferty',
'where' => 't.post_status="Publish"',
'order' => 'ASC',
'orderby' => 'field_order_withnulls post_date',
'posts_per_page' => 6,
'tax_query' => array(
array(
'taxonomy' => 'offers-categories',
'field' => 'term_id',
'terms' => $category->term_id,
),
),
'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1,
'meta_query' => array(
'relation' => 'OR',
'field_order' => array(
'key' => 'already_rented',
'compare' => 'EXISTS',
),
'field_order_withnulls' => array(
'key' => 'already_rented',
'compare' => 'NOT EXISTS',
)
)
);
$query = new WP_Query($args);
if ($query->have_posts()) : ?>
<ul class="offer-list offer-list--grid list">
<?php while($query->have_posts()) : $query->the_post();
$count = $query->found_posts;
?>
<?php
// ACF
$image = get_field('image') ? get_field('image') : '/wp-content/uploads/woocommerce-placeholder.png';
$estate_type = get_field('estate_type') ?? '';
$transaction_type = get_field('transaction_type') ?? '';
$location = get_field('location') ?? '';
$district = get_field('district') ?? '';
$area = get_field('area') ? $area . 'm<sup>2</sup>' : '';
$rent_price_m2 = get_field('rent_price_m2') ? $rent_price_m2 . 'zł/m<sup>2</sup>' : '';
$rent_price_total = get_field('rent_price_total') ? $rent_price_total . ' zł' : '';
$operating_costs_m2 = get_field('operating_costs_m2') ? $operating_costs_m2 . 'zł/m<sup>2</sup>' : '';
$operating_costs_total = get_field('operating_costs_total') ? $operating_costs_total . ' zł' : '';
$features_obj = get_field_object('features') ?? '';
$features = $features_obj['value'];
$offer_number = get_field('offer_number') ?? '';
$already_rented = get_field('already_rented');
?>
<li class="offer">
<?php if ($already_rented == 1) { ?>
<span class="offer__already_rented">
już wynajęte
</span>
<?php } ?>
<img class="offer__img" src="<?php echo $image; ?>" alt="">
<div class="offer-about">
<div class="offer-about__link">
<?php
if ($location) {
echo $location;
}
if ($district) {
echo " " . $district;
}
?>
</div>
<?php if ($location) { ?>
<div class="location-town-wrapper">
<img src="/wp-content/uploads/2023/08/marker-ico.svg" alt="">
<span class="location-town">Wrocław</span>
</div>
<?php } ?>
<div class="offer-info">
<div>
<div class="offer-info__txt">Powierzchnia: <b>69.53 m<sup>2</sup></b></div>
<div class="offer-info__txt">Czynsz:<b> 55 zł/m<sup>2</sup></b> (3 824 zł)</div>
<div class="strenghts__wrap">
<p>Wyposażenie:</p>
<span class="strengths">
<span class="strengths__item">
<i class="offer-icon offer-icon--clima" title="Klimatyzacja"></i>
</span>
<span class="strengths__item">
<i class="offer-icon offer-icon--elevator" title="Winda"></i>
</span>
<span class="strengths__item">
<i class="offer-icon offer-icon--security" title="Ochrona"></i>
</span>
<span class="strengths__item">
<i class="offer-icon offer-icon--parking" title="Parking"></i>
</span>
<span class="strengths__item">
<i class="offer-icon offer-icon--service" title="Recepcja"></i>
</span>
</span>
</div>
</div>
</div>
<a class="elementor-button elementor-button--offer elementor-button-link elementor-size-md" href="<?php echo get_permalink(); ?>">
<span class="elementor-button-content-wrapper">
<span class="elementor-button-text">
Czytaj więcej
</span>
</span>
</a>
</div>
</li>
<?php endwhile; ?>
</ul>
<?php
else :
echo '<p style="text-align:center;padding: 0 0 50px;font-size:20px!important;">Nie znaleziono ofert.</p>';
endif;
wp_reset_postdata();
?>
<?php
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$current_page = max(1, get_query_var('page'));
echo '<div class="home-pagination">';
echo paginate_links(array(
'base' => get_pagenum_link() . '%_%',
'format' => 'page/%#%',
'total' => $query->max_num_pages,
'prev_text' => __('« poprzednia'),
'next_text' => __('następna »'),
'page' => $paged
));
echo '</div>';
?>Editor is loading...