J
J
jamster2018-03-24 13:32:08
WordPress
jamster, 2018-03-24 13:32:08

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

1 answer(s)
O
Orkhan Hasanli, 2018-03-24
@azerphoenix

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(); ?>

Custom pagination - dimox.name/wordpress-pagination-without-a-plugin
Result: https://md7.info/fakty

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question