Answer the question
In order to leave comments, you need to log in
Post__in + ACF: all digits are not extracted or how to paginate the ACF "posts"?
Good time, dear experts! Tell me how to make pagination for the selected records of their "Posts" field in the ACF plugin
Option No. 1 (preferably)
I output the posts with the following code:
<?php $id_page_services_id = get_field( 'id_page_services_id' ); ?>
<?php if ( $id_page_services_id ) : ?>
<?php foreach ( $id_page_services_id as $post ) : ?>
<?php setup_postdata ( $post ); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
<div class="row grid img-reset">
<?php
$idsss = get_field( 'id_page_services_id' ); // Кладу в переменную числа из поля (Пример - 250, 265, 669, 243)
$argss = array(
'posts_per_page' => 12,
'paged' => $paged,
'post_type' => 'page',
'post_parent__in' => array( $idss ), // Не работает т.к. надо (для примера)
'post__in' => array( $idsss ), // Не работает т.к. надо
'post__in' => [ $idsss ], // Не работает т.к. надо
'post__in' => [ 250, 265, 669, 243 ], // Так идеально работает
)
?>
<?php
$count_items = 1;
$paged = get_query_var( 'paged', 1 );
$twoprocedd = new WP_Query( $argss );
?>
<?php if ( $twoprocedd->have_posts() ) { while ( $twoprocedd->have_posts() ) { $twoprocedd->the_post(); ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
<div class="col-lg-4 col-sm-6" style="padding-top:30px">
<figure class="effect-bubba" style="position:relative">
<?php the_post_thumbnail('thumbs-all'); ?>
<figcaption>
<div class="block-table">
<div class="block-table-cell">
<div class="h4"><?php the_title(); ?></div>
<div class="subname top-15"><?php the_excerpt(); ?></div>
</div>
</div>
</figcaption>
</figure>
</div>
</a>
<?php } ?>
<?php wp_reset_query(); ?>
<?php } else { ?>
<p>Нет записей для отображения.</p>
<style>.last-bl-none-two {display: none;}</style>
<?php } ?>
</div>
Answer the question
In order to leave comments, you need to log in
If the variable contains a id_page_services_id
string, 250, 265, 669, 243
then first you need to make an array out of it, for example like this:
$idsss = get_field( 'id_page_services_id' );
$idsss = explode(', ', $idsss);
$idsss = array_filter($idsss);
'post__in' => $idsss
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question