我想在single-ediciones.php
文件和我需要分页(实际上是AJAX分页)。
我需要我的普通循环,因为我需要显示CPT“指令”的一些数据,我需要一个自定义循环,以通过ID显示与当前CPT相关的一些CPT。
实际上,我不知道是否可能有一个普通的循环,并且在一个带有分页的自定义循环中。
现在我可以拿到"ALL_THE_URL/page/2"
工作,但不分页。甚至使用new WP_Query
并添加get_next_posts_link( \'Older Entries\', $the_query->max_num_pages );
.
<?php if ( have_posts() ) :
while( have_posts() ) : the_post();
$edicion_ID = get_the_ID();
$edicion_titulo = get_the_title();
$edicion_titulo = strtolower($edicion_titulo); ?>
<div class="container ediciones-detalle-contenedor">
<div class="row">
<div class="col-md-4 col-md-push-8 col-sm-4 col-sm-push-8">
<h3><?php echo $edicion_titulo; ?></h3>
</div>
<div class="col-md-8 col-md-pull-4 col-sm-8 col-sm-pull-4">
<div class="row">
<?php
$paged = ( get_query_var( \'paged\' ) ) ? get_query_var( \'paged\' ) : 1;
$args = array(
\'numberposts\' => 4,
\'post_type\' => array(\'temas\', \'perfiles\', \'udem-mundo\', \'deportes\', \'cultura\'),
\'meta_query\' => array(
\'relation\' => \'AND\',
array(
\'key\' => \'contenido_relacionado_impreso\',
\'value\' => \'si\',
\'compare\' => \'=\',
),
array(
\'key\' => \'contenido_relacionado_edicion\',
\'value\' => $edicion_ID,
\'compare\' => \'=\',
),
),
\'paged\' => $paged,
);
$posts_relacionados_edicion = get_posts($args);
if ( !empty($posts_relacionados_edicion) ) :
foreach ($posts_relacionados_edicion as $post) : setup_postdata( $post ); ?>
<div class="col-md-6 col-sm-6">
<a href="<?php the_permalink(); ?>" class="blog-titulo-chico"><h3><?php the_title(); ?></h3></a>
</div>
<?php endforeach;
wp_reset_postdata();
endif; ?>
</div>
</div>
</div>
</div>
<?php endwhile;
endif; ?>