Not getting Next posts link
-
I have built a custom page template where user will be able to see his favourite posts i am using this code
`<?php $user_fav = get_user_favorites($user_id);
$paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1;
$args = array(
‘posts_per_page’ => 4,
‘post_type’ => array(‘communityposts’,’post’,’video’),
‘post__in’ => $user_fav,
‘post_status’ => ‘publish’,
‘suppress_filters’ => true ,
‘paged’ => $paged
);
$loop = new WP_Query( $args );
if( $loop->have_posts()):while($loop->have_posts()):$loop->the_post();
?><article class=”post-items-latest”>
<a href=”<?php echo get_permalink( $post->ID ); ?>” title=”<?php the_title(); ?>”>
<span class=”image-wrapper”><?php
$thumb = get_post_thumbnail_id($post->ID);
$img_url = wp_get_attachment_url( $thumb,’full’ ); //get full URL to image (use “large” or “medium” if the images too big)
?>
<img src=”<?php echo $img_url; ?>” alt=”<?php the_title(); ?>” width=”226″ height=”117″></span>
<h1><?php the_title(); ?></h1>
</a>
<div class=”post-footer”>
<span class=”user”><i class=”fa fa-user”></i> <?php echo get_the_author_link(); ?></span>
<span class=”data”><i class=”fa fa-clock-o”></i> <?php wp_days_ago_v3(); ?></span>
<span class=”likes”><i class=”fa fa-eye”></i> <?php echo $meta_values = get_post_meta( get_the_ID(), ‘cv_post_views_count’, true ); ?> </span>
</div>
</article><?php
endwhile;
endif;
wp_reset_query();
?><div class=”post-nav-container”>
<?php previous_posts_link( __(‘→ Older Posts’)); ?>
<?php next_posts_link( __(‘Newer Posts ← ‘,$loop->max_num_pages)); ?>
</div>`I am not able to get the links to the next page as my website is having high traffic and user will gonna use this functionality , so i don’t want this custom page to load lot of post at the same time , then the page will be slow, so better if i can add navigation links to the next posts and previous posts.
The topic ‘Not getting Next posts link’ is closed to new replies.