Saya memiliki pertanyaan yang mengembalikan Properti untuk Disewakan/Dijual di halamannya masing-masing, apa pun yang saya coba, saya tidak bisa mendapatkan kueri tersebut ke halaman yang berhasil.
Salah satu halaman yang ingin saya gunakan pagination adalah http://www.urbanvision.org.uk/services/property-services/properties-for-sale/.
Saya ingin penomoran halaman dan mencoba menggunakan WP Navi tetapi PHP saya kacau dan saya mendapat pesan kesalahan ketika mencoba mengakses halaman yang diterbitkan.
Kode saya saat ini adalah:
<?php
$featuredPosts = new WP_Query();
$featuredPosts->query('showposts=100&cat=13');
while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>
<div class="literaturedescription">
<?php
$prop_det_url = get_field('property_details_url');
if($prop_det_url!=''){ ?>
<a href="/id<?php echo $prop_det_url; ?>" target="_blank" title="<?php the_field('property_title'); ?>">
<img src="<?php the_field('property_thumbnail'); ?>" width="220px" height="150px" alt="<?php the_field('property_title'); ?>" /></a>
<?php } else { ?>
<a href="/id<?php the_field('property_details'); ?>" title="<?php the_field('property_title'); ?>" target="_blank">
<img src="<?php the_field('property_thumbnail'); ?>" width="220px" height="150px" alt="<?php the_field('property_title'); ?>" /></a>
<?php } ?>
<p><strong><?php the_field('property_title'); ?></strong><br /><?php the_field('property_excerpt'); ?> <span style="color:red;font-weight:bold;"><?php the_field('property_status'); ?></span>
<?php
$prop_det_url = get_field('property_details_url');
if($prop_det_url!=''){ ?>
<br /><a href="/id<?php echo $prop_det_url; ?>" target="_blank" title="<?php the_field('property_title'); ?>">> > View Details</a></p><br />
<?php } else { ?>
<br /><a href="/id<?php the_field('property_details'); ?>" target="_blank" title="<?php the_field('property_title'); ?>">> > View Details</a></p><br />
<?php } ?>
</div>
<div class="clear"></div>
<?php endwhile; ?>
Ini sampai pada titik bahwa kita akan menambahkan lebih banyak properti dan idealnya menginginkan halaman dengan 10 atau 20 posting per halaman.
Pembaruan untuk menunjukkan Kode yang telah saya coba terapkan:
<?php
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1
$featuredPosts = new WP_Query();
$featuredPosts = new WP_Query( array( 'posts_per_page' => 10, 'cat' => 13, 'paged' => $paged);
while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>
<div class="literaturedescription">
<?php
$prop_det_url = get_field('property_details_url');
if($prop_det_url!=''){ ?>
<a href="/id<?php echo $prop_det_url; ?>" target="_blank" title="<?php the_field('property_title'); ?>">
<img src="<?php the_field('property_thumbnail'); ?>" width="220px" height="150px" alt="<?php the_field('property_title'); ?>" /></a>
<?php } else { ?>
<a href="/id<?php the_field('property_details'); ?>" title="<?php the_field('property_title'); ?>" target="_blank">
<img src="<?php the_field('property_thumbnail'); ?>" width="220px" height="150px" alt="<?php the_field('property_title'); ?>" /></a>
<?php } ?>
<p><strong><?php the_field('property_title'); ?></strong><br /><?php the_field('property_excerpt'); ?> <span style="color:red;font-weight:bold;"><?php the_field('property_status'); ?></span>
<?php
$prop_det_url = get_field('property_details_url');
if($prop_det_url!=''){ ?>
<br /><a href="/id<?php echo $prop_det_url; ?>" target="_blank" title="<?php the_field('property_title'); ?>">> > View Details</a></p><br />
<?php } else { ?>
<br /><a href="/id<?php the_field('property_details'); ?>" target="_blank" title="<?php the_field('property_title'); ?>">> > View Details</a></p><br />
<?php } ?>
</div>
<div class="clear"></div>
<?php endwhile; ?>
<?php wp_reset_postdata() ?>
<?php wp_pagenavi( array( 'query' => $featuredPosts) ); ?>