I have created a page where user can see his favourite post which has been bookmarked by him
get_user_favorites($user_id);
This function is responsible for returning me all the favourite posts bookmarked by user in an array.
I am using this approach to get the data from the database and make it work inside my Custom Html.
<?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
);
$posts_array = get_posts( $args );
foreach ($posts_array as $p) :
?>
<article class="post-items-latest">
<a href="<?php echo get_permalink( $p->ID ); ?>" title="<?php echo $p->post_title; ?>">
<span class="image-wrapper">
<?php
$thumb = get_post_thumbnail_id($p->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 $p->post_title; ?>" width="226" height="117">
</span>
<h1><?php echo $p->post_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 endforeach; ?>
<div class="post-nav-container">
<?php previous_posts_link( __('→ Older Posts','circoviral')); ?>
<?php next_posts_link( __('← Older Posts','circoviral')); ?>
</div>
Using this approach i am able to get the Favourited post by an User but i am not able to make the next_posts_link();
and previous_posts_link();
work inside my template
Is there anything i am doing wrong ?