The Stack Overflow podcast is back! Listen to an interview with our new CEO.
2 question clarity
source | link

How can I conditionally show adifferent home page templates based on whether or not the user is logged in?

How can I conditionally load HTML for the home page based on whether or not the user is logged in?

Currently my theme has an index.php file. In that file I tried to create:

<?php
if(is_user_logged_in()) {
 get_header(); ?>
<div id="primary" class="content-area">
    <div class="primary-inner">
        <div id="content" class="site-content content-list" role="main">
        <?php 
        if ( have_posts() ) : 
            while ( have_posts() ) : the_post(); 
                get_template_part( 'content', get_post_format() ); 
            endwhile;
            dw_minion_content_nav( 'nav-below' ); 
        else : 
            get_template_part( 'no-results', 'index' ); 
        endif; 
        ?>
        </div>
    </div>
</div>
<?php get_sidebar('secondary'); ?>
<?php get_footer(); ?>
<?php } else { ?>
    // load plain ol' static boring HTML here with a login widget area.
<?php
} ?>

However, this doesn't work. In fact, no matter what I change in the index.php file, nothing else changes. I can even delete the file and it works fine!!

I can see that I have a header.php file. If I modify that file, then I can see changes appear. But, that means I'd have to modify that, footer.php, page.php, content.php etc etc, ultimately having multiple files that have conditional logic in them.

I'm new to developing in Wordpress. There has to be a better way to do this right?

If the person is not logged in, a completely different home page template / design should show up that has one single widget area where the WP login form (bp login widget) shows up. Once that person is logged in, the normal home page with default template should appear.

In Reading, a static page is set and it has a template of "Default Template."

How can I conditionally show a home page based on whether or not the user is logged in?

How can I conditionally load HTML for the home page based on whether or not the user is logged in?

Currently my theme has an index.php file. In that file I tried to create:

<?php
if(is_user_logged_in()) {
 get_header(); ?>
<div id="primary" class="content-area">
    <div class="primary-inner">
        <div id="content" class="site-content content-list" role="main">
        <?php 
        if ( have_posts() ) : 
            while ( have_posts() ) : the_post(); 
                get_template_part( 'content', get_post_format() ); 
            endwhile;
            dw_minion_content_nav( 'nav-below' ); 
        else : 
            get_template_part( 'no-results', 'index' ); 
        endif; 
        ?>
        </div>
    </div>
</div>
<?php get_sidebar('secondary'); ?>
<?php get_footer(); ?>
<?php } else { ?>
    // load plain ol' static boring HTML here with a login widget area.
<?php
} ?>

However, this doesn't work. In fact, no matter what I change in the index.php file, nothing else changes. I can even delete the file and it works fine!!

I can see that I have a header.php file. If I modify that file, then I can see changes appear. But, that means I'd have to modify that, footer.php, page.php, content.php etc etc, ultimately having multiple files that have conditional logic in them.

I'm new to developing in Wordpress. There has to be a better way to do this right?

If the person is not logged in, a completely different home page design should show up that has one single widget area where the WP login form (bp login widget) shows up. Once that person is logged in, the normal home page with default template should appear.

How can I conditionally show different home page templates based on whether or not the user is logged in?

How can I conditionally load HTML for the home page based on whether or not the user is logged in?

Currently my theme has an index.php file. In that file I tried to create:

<?php
if(is_user_logged_in()) {
 get_header(); ?>
<div id="primary" class="content-area">
    <div class="primary-inner">
        <div id="content" class="site-content content-list" role="main">
        <?php 
        if ( have_posts() ) : 
            while ( have_posts() ) : the_post(); 
                get_template_part( 'content', get_post_format() ); 
            endwhile;
            dw_minion_content_nav( 'nav-below' ); 
        else : 
            get_template_part( 'no-results', 'index' ); 
        endif; 
        ?>
        </div>
    </div>
</div>
<?php get_sidebar('secondary'); ?>
<?php get_footer(); ?>
<?php } else { ?>
    // load plain ol' static boring HTML here with a login widget area.
<?php
} ?>

However, this doesn't work. In fact, no matter what I change in the index.php file, nothing else changes. I can even delete the file and it works fine!!

I can see that I have a header.php file. If I modify that file, then I can see changes appear. But, that means I'd have to modify that, footer.php, page.php, content.php etc etc, ultimately having multiple files that have conditional logic in them.

I'm new to developing in Wordpress. There has to be a better way to do this right?

If the person is not logged in, a completely different home page template / design should show up that has one single widget area where the WP login form (bp login widget) shows up. Once that person is logged in, the normal home page with default template should appear.

In Reading, a static page is set and it has a template of "Default Template."

1
source | link

How can I conditionally show a home page based on whether or not the user is logged in?

How can I conditionally load HTML for the home page based on whether or not the user is logged in?

Currently my theme has an index.php file. In that file I tried to create:

<?php
if(is_user_logged_in()) {
 get_header(); ?>
<div id="primary" class="content-area">
    <div class="primary-inner">
        <div id="content" class="site-content content-list" role="main">
        <?php 
        if ( have_posts() ) : 
            while ( have_posts() ) : the_post(); 
                get_template_part( 'content', get_post_format() ); 
            endwhile;
            dw_minion_content_nav( 'nav-below' ); 
        else : 
            get_template_part( 'no-results', 'index' ); 
        endif; 
        ?>
        </div>
    </div>
</div>
<?php get_sidebar('secondary'); ?>
<?php get_footer(); ?>
<?php } else { ?>
    // load plain ol' static boring HTML here with a login widget area.
<?php
} ?>

However, this doesn't work. In fact, no matter what I change in the index.php file, nothing else changes. I can even delete the file and it works fine!!

I can see that I have a header.php file. If I modify that file, then I can see changes appear. But, that means I'd have to modify that, footer.php, page.php, content.php etc etc, ultimately having multiple files that have conditional logic in them.

I'm new to developing in Wordpress. There has to be a better way to do this right?

If the person is not logged in, a completely different home page design should show up that has one single widget area where the WP login form (bp login widget) shows up. Once that person is logged in, the normal home page with default template should appear.