Last active
January 18, 2016 20:20
-
-
Save gugaalves/7c2ec2305a5e20eef00f to your computer and use it in GitHub Desktop.
Mostrar posts privados apenas pro autor deste post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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