Skip to content

Instantly share code, notes, and snippets.

@gugaalves
Last active January 18, 2016 20:20
Show Gist options
  • Save gugaalves/7c2ec2305a5e20eef00f to your computer and use it in GitHub Desktop.
Save gugaalves/7c2ec2305a5e20eef00f to your computer and use it in GitHub Desktop.
Mostrar posts privados apenas pro autor deste post
if ( have_posts() ) :
while ( have_posts() ) : the_post();
// the loop
$checkpost = get_post_status ( post->ID );
$author_id = the_author_meta('ID', post->ID);
$user_id = get_current_user_id();
$private = get_post_custom_values('private'); // read custom field
if ( $checkpost == 'private' && $user_id == $author_id ) {
// display private post, only logged user who had posted this post
} else {
// display public post, for every visitors
}
endwhile;
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment