Пользовательские проблемы постраничного типа

Возникли проблемы с реализацией нумерации страниц для пользовательского типа записи («транспортное средство») в дочерней теме Genesis, я использую Genesis: 2.0.0 в WordPress 4.1.1

Я попытался поместить следующий код в function.php
add_filter (‘genesis_prev_link_text’, ‘gt_review_prev_link_text’);

function gt_review_prev_link_text() {
$prevlink = '« Previous Reviews';
return $prevlink;
}
add_filter( 'genesis_next_link_text', 'gt_review_next_link_text' );
function gt_review_next_link_text() {
$nextlink = 'Next Reviews »';
return $nextlink;
}

я тоже попробовал следующее;

<?php genesis_posts_nav();?>

Приведенный ниже код работает, но только как «новые» и «старые» гиперссылки, я пытаюсь добиться нумерации страниц.

<?php previous_posts_link( '« Newer' ); ?>
<?php next_posts_link( 'Older »', $vehicle->max_num_pages ); ?>

Вот мой собственный шаблон архива типа поста.

<?php
/*
Template Name: Archive Vehicle(CAR)
*/
//* Force full width content
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
//* Remove Post Info
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );

//* Remove Post Meta
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
/** Code for custom loop */

remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'am_custom_loop' );
function am_custom_loop(){
$paged = 1;
if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); }
if ( get_query_var( 'page' ) ) { $paged = get_query_var( 'page' ); }
$paged = intval( $paged );
$args = array('post_type' => 'vehicle', 'posts_per_page' => '3', 'paged'=> $paged, );
$vehicle = new WP_query($args);
$wp_query = $vehicle;
if ($vehicle -> have_posts() ){
?>
<div class="first arc">
<h2> View our latest used car collection from KH cars Birmingham</h2>
<p>Need a car?  Look no further, browse through our vast selection of used cars on site based in Birmingham.  </p>
</div>
<?php
while ($vehicle -> have_posts() ){
$vehicle -> the_post();

?>

<div class="first archivecar">
<div class="one-fourth">
<?php
$images = get_field('image');
if( $images ):
$image = $images[0];
?>
<a href="<?php the_permalink($id); ?>">
<img src="<?php echo $images[0]['sizes']['large']; ?>" alt="<?php echo $image['alt']; ?>" />
</a>
<?php endif; ?>
</div>
<div class="two-fourths">
<br>
<h3><a  style="text-decoration:none;" href="<?php the_permalink($id) ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<ul class="carinfo">
<li><p> Year: <?php $terms = get_the_terms( $post->ID , 'year', 'year' );
// Loop over each item since it's an array
if ( $terms != null ){
foreach( $terms as $term ) {
// Print the name method from $term which is an OBJECT
print $term->name ;
// Get rid of the other data stored in the object, since it's not needed
unset($term);
} } ?></p></li>
<li><p> Trans: <?php $terms = get_the_terms( $post->ID , 'trans', 'trans' );
// Loop over each item since it's an array
if ( $terms != null ){
foreach( $terms as $term ) {
// Print the name method from $term which is an OBJECT
print $term->name ;
// Get rid of the other data stored in the object, since it's not needed
unset($term);
} } ?></p></li>
<li><p> Fuel:
<?php   // Get terms for post
$terms = get_the_terms( $post->ID , 'fuel', 'fuel' );
// Loop over each item since it's an array
if ( $terms != null ){
foreach( $terms as $term ) {
// Print the name method from $term which is an OBJECT
print $term->name ;
// Get rid of the other data stored in the object, since it's not needed
unset($term);
} } ?></li>
<?php if( get_field('Mileage') ): ?>
<li><p> Mileage: <?php the_field('Mileage');?></p></li>
<?php endif; ?>
<li><p>Color: <?php $terms = get_the_terms( $post->ID , 'colours', 'colours' );
// Loop over each item since it's an array
if ( $terms != null ){
foreach( $terms as $term ) {
// Print the name method from $term which is an OBJECT
print $term->name ;
// Get rid of the other data stored in the object, since it's not needed
unset($term);
} } ?></p></li>
<?php if( get_field('owners') ): ?>
<li><p>Owners: <?php $terms = get_the_terms( $post->ID , 'owners', 'owners' );
// Loop over each item since it's an array
if ( $terms != null ){
foreach( $terms as $term ) {
// Print the name method from $term which is an OBJECT
print $term->name ;
// Get rid of the other data stored in the object, since it's not needed
unset($term);
} }?></p></li>
<?php endif; ?>
</ul>
</div>
<div class="one-fourth">

<?php if ( get_field('price')):?>
<p class="price"><?php the_field('price');?></p>
<?php endif; ?>
<a class="btn" style="text-align:center" href="<?php the_permalink() ?>">view Details</a>
</div>
</div>
<?php
}
?>
<?php genesis_posts_nav();?>
<?php wp_reset_query();?>
<?php
}
}
genesis();

Буду признателен за любую оказанную помощь. заранее спасибо

0

Решение

Сначала я удалил $ wp_query = $ vehicle; а затем использовал код ниже из WordPress Codex и вуаля это работает.

<?php
$big = 999999999; // need an unlikely integer

echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $vehicle->max_num_pages
) );
?>
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector