wp_get_archives() --> only show posts, a user is allowed to read?

by simzyk   Last Updated July 19, 2018 09:08 AM

i'm trying to build a navigation in which all posts are listed in a sidebar (all the time) -> but only the ones a user is allowed to see.

i tried to do this with wp_get_archives() which gives me a list of all posts - but i don't know how to filter restricted posts from here?

Another try was to simply build a "title only version" of the loop:

  <?php if (have_posts()) : ?>
    <ul>
      <?php while (have_posts()) :
        the_post(); ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </li>
      <?php endwhile; ?>
    </ul>
  <?php endif;?>

This worked better for the first part, because it only showed me the posts i wanted to be listed. But if i clicked on a link to open a post (.../wordpress/?p=ID) the nature of the loop let's all the other listings disappear. Is there a way to stop this behavior? Or is there another way i should try?

Greetings

simzyk



Related Questions


Display post previews only to resistered users?

Updated April 04, 2015 06:03 AM


Wordpress restriction to the whole website

Updated July 11, 2016 08:03 AM