• kpizme

    (@kpizme)


    I have been trying to code a way that will display “Private” next to a post title, when a post has been marked as such. Has anyone had success with this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Kafkaesqui

    (@kafkaesqui)

    Marked as in post status? WordPress does this automatically in the admin pages. If it’s for a post displayed publically, the post *won’t* display when set to private, so…you might want to provide a bit more info on how you’ve “marked” a post private, and where exactly you need to display this.

    Thread Starter kpizme

    (@kpizme)

    Well, this is in follow-up to the implemenation of the post-level plug-in, by Filipe Fortes. If a user has a user level sufficient enough to see a post deemed “private” I would like to indicate so. This way, the user will know they are viewing a post that not everyone can see.

    http://fortes.com/projects/wordpress/postlevels%5D

    Thanks for the query.

    Kafkaesqui

    (@kafkaesqui)

    Ah, clear now.

    Try something like this to get what you’re after:

    <?php if('private' == $post->post_status) { echo "Private!"; } ?>

    Thread Starter kpizme

    (@kpizme)

    Ah yes, that will do it! I was attepmting an “if-then-else” statement, but this is even better! Thanks!

    Post Levels v0.2 has a function you can use for this: is_private. The sample code you can use is:

    <?php if (function_exists('is_private') && is_private()) : ?>
    <span class="private">(private)</span>
    <?php endif;?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display “Private”’ is closed to new replies.