Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( have_posts() ) :
- while ( have_posts() ) : the_post();
- // the loop
- $private = get_post_custom_values('private'); // read custom field
- if (isset($private[0]) && $private[0] == 'yes' ) { // if the post is private
- if ( is_user_logged_in() ) {// and if the user is logged in
- // display private post ?>
- <div>
- <h4><?php the_title(); ?></h4>
- <?php get_post_custom_keys();?>
- <p><?php the_content(); ?></p>
- <p><a href="<?php echo get_post_meta($post->ID, "resourcelink", true); ?>">Resource Link</a></p>
- <?php if (get_post_meta($post->ID, "private", true)==yes) {?>
- <p class="private">This document private.</p>
- <?php } ?>
- </div>
- <?php }
- else { // if the user is not logged in
- // want make the a login link, with redirect back to this page
- // but now just tells user to log in ?>
- <div>
- echo the_title('<h4>','</h4>');
- get_post_custom_keys();?>
- <p><?php the_content(); ?></p>
- <?php echo '<p>Private resource — please log in to read.</p>';
- }
- }
- else { // if the post is public
- // display public post, for every visitor ?>
- <div>
- <h4><?php the_title(); ?></h4>
- <?php get_post_custom_keys();?>
- <p><?php the_content(); ?></p>
- <p><a href="<?php echo get_post_meta($post->ID, "resourcelink", true); ?>">Resource Link</a></p>
- </div>
- <?php }
- endwhile;
- endif;
- ?>
Add Comment
Please, Sign In to add comment