• I visited this page to figure out how to make a page require a login before displaying its content. It works great but now it changes everything about how the page looks.

    My website is here: https://www.paulegavin.net , the problem page is “Students & Clients.”

    It looks fine if a user is logged in but looks different if they’re not. I’d like it to look the same as the rest of the site.

    I imagine I’m putting the “if login” in the wrong place. This is the code I currently have for the page template:

    <?php
    /*
    Template Name: Students & Clients
    */
    ?>
    
    <?php
    if(!is_home() ){
    	get_header(); ?>
    	<div id="<?php $meta = get_post_meta($post->ID, $field['id'], true); echo substr($meta['connection'][0], 1); ?>" class="section single">
    
    <?php
    }
    ?>
        <div class="heading">
          <div class="heading_cont">
    		<a href="#main" class="go_up"></a>
            <h1><?php the_title(); ?></h1>
            <span class="heading_bg"></span>
            <!--end heading_bg-->
          </div>
          <!--end heading_cont-->
        </div>
        <!--end heading-->
                            <?php if(is_user_logged_in()):?>
        <div class="content_left">
    
    	<?php
    	if(!is_home()){
    		while (have_posts()) { the_post();
    			the_content('');
    		}
    		wp_reset_query();  // Restore global post data
    	}
    	else
    	{
    		the_content('');
    	}?>
        </div>
    
        <!--end content_left-->
    
    	<div class="sidebar_right">
    		<ul class="sidebar">
    			<?php dynamic_sidebar( 'sidebar-right' ); ?>
    		</ul>
        </div>
        <!--end sidebar_right-->
    
    <?php
    if(!is_home()){?>
    	</div>
    <?php get_footer();
    }
    ?>
    <?php else:
    wp_die('Sorry, you must first <a href="/wp-login.php">log in</a> to view this page. You can <a href="/wp-login.php?action=register">register free here</a>.');
    endif;?>

    Thanks very much!

  • The topic ‘Using changes page appearance’ is closed to new replies.