Answer the question
In order to leave comments, you need to log in
Post navigation in wordpress page?
Good day, all experts in wordpress and its technical part. There was a problem, it is necessary to implement navigation to the pages to which records are attached through the "relationship" of the advanced custom field plugin.
As I understand it, posts are displayed through the WP_Post class.
The output of records is organized in this way.
1. I receive value. $posts = get_field('page_get_rubrik');
2. Loop <?php foreach( $posts as $post): displays posts on the page
Actually I couldn't figure out how to implement post navigation, and limit the number of posts per page. Thanks for answers. If something is not clear explained, I will add, I will overflow. Please help me decide :)
Answer the question
In order to leave comments, you need to log in
Hello!
As I understand from your question, you want to display a cycle of posts and custom fields for them and at the same time limit the number of posts per page and add navigation (pagination).
If yes, then here is the finished code:
<?php global $wp_query;
$wp_query = new WP_Query(array(
'posts_per_page' => '12', // кол-во записей на страницу
'post_type' => 'post', // тип записи.
'paged' => get_query_var('paged') ?: 1 // страница пагинации
));
while( have_posts() ) { the_post();
// Здесь ваш код и кастомные поля
// Например,
?>
<h2><?php the_title (); ?></h2>
<?php the_field('custom_field'); ?>
<?php }
// пагинация
if (function_exists('wp_corenavi')) wp_corenavi(); // кастомная пагинация, которую я использую
wp_reset_query(); ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question