我试图在自定义帖子类型中显示paginate\\u links函数。但它并没有出现在网站上。以下是循环:
<div class="container">
<?php
$objekte_args = array(
\'post_type\' => \'objekte\',
\'posts_per_page\' => \'1\'
)
?>
<?php $objekte = new WP_Query( $objekte_args ); ?>
<?php if ( $objekte->have_posts() ) : ?>
<?php while ( $objekte->have_posts() ) : $objekte->the_post(); ?>
<div class="row">
<div class="col-md-push-1 col-md-4">
<h2>
<?php _e( \'Objekte\', \'ryvola\' ); ?>
</h2>
<div class="projects__project-title">
<span class="projects__project-title--headline"><?php the_title(); ?></span>
<?php the_content(); ?>
</div>
<?php echo paginate_links( array(
\'format\' => \'?paged=%#%\'
)); ?>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p>
<?php _e( \'default\', \'ryvola\' ); ?>
</p>
<?php endif; ?>
</div>
我做错了什么?
SO网友:MagniGeeks Technologies
你能试试这个,看看它是否对你有用吗?
<div class="container">
<?php
// set up or arguments for our custom query
$paged = ( get_query_var(\'page\') ) ? get_query_var(\'page\') : 1;
$objekte_args = array(
\'post_type\' => \'objekte\',
\'posts_per_page\' => 1,
\'paged\' => $paged
);
?>
<?php $objekte = new WP_Query( $objekte_args ); ?>
<?php if ( $objekte->have_posts() ) : ?>
<?php while ( $objekte->have_posts() ) : $objekte->the_post(); ?>
<div class="row">
<div class="col-md-push-1 col-md-4">
<h2>
<?php _e( \'Objekte\', \'ryvola\' ); ?>
</h2>
<div class="projects__project-title">
<span class="projects__project-title--headline"><?php the_title(); ?></span>
<?php the_content(); ?>
</div>
<?php echo paginate_links( array(
\'format\' => \'?paged=%#%\'
)); ?>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p>
<?php _e( \'default\', \'ryvola\' ); ?>
</p>
<?php endif; ?>
</div>