Query has different response if user is logged in

I have small problem with this query. If user is any logged in everything works as it should, but when guest opens the page, this creates quite random results and following links doesn’t work. Could You help me with that?

$next_prev_query_args = array('post_type' => array( 'remix', 'alluploads' ),'fields' => 'ids','showposts'=>-1,'meta_key' => '_is_ns_featured_post','meta_value' => 'yes');
    $next_prev_query = get_posts( $next_prev_query_args );
    $postid=$post->ID;
    $datanp=next_prev_posts($next_prev_query,$postid);

And

<?php if($datanp[0]!='' && $datanp[1]!='') { ?>
<a class="next-post" href="<?php echo get_permalink($datanp[0]); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/nexts_arrow.png"/></a>
<a class="prev-post" href="<?php echo get_permalink($datanp[1]); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/prevs_arrow.png"/></a>

Read more here: Query has different response if user is logged in

Leave a Reply

Your email address will not be published. Required fields are marked *