forked from weblab/cornerstone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modifications to page.php to support subpage sidebars
- Loading branch information
Showing
1 changed file
with
63 additions
and
63 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,63 @@ | ||
<?php | ||
/** | ||
* The template for displaying all pages. | ||
* | ||
* This is the template that displays all pages by default. | ||
* Please note that this is the WordPress construct of pages | ||
* and that other 'pages' on your WordPress site will use a | ||
* different template. | ||
* | ||
* @package cornerstone | ||
*/ | ||
|
||
get_header(); ?> | ||
<h1>page.php</h1> | ||
<?php | ||
// sidebar custom field check. | ||
$sidebar = get_post_meta( get_the_ID(), 'uc_sidebar', true ); | ||
if( !is_active_sidebar( $sidebar ) ){ | ||
foreach(get_post_ancestors(get_the_ID()) as $ancestor){ | ||
$parent_sidebar = get_post_meta( $ancestor, 'uc_sidebar', true ); | ||
$parent_sidebar_children = get_post_meta( $ancestor, 'uc_sidebar_children', true ); | ||
if( is_active_sidebar( $parent_sidebar ) && $parent_sidebar_children != '' && $parent_sidebar_children ){ | ||
$sidebar = $parent_sidebar; | ||
break; | ||
} | ||
} | ||
} | ||
?> | ||
<div class="row"> | ||
<div class="col-sm-<?php echo (is_active_sidebar( $sidebar )?9:12); ?>"> | ||
<div id="primary" class="content-area"> | ||
<main id="main" class="site-main" role="main"> | ||
<h1>Sidebar?</h1> | ||
<?php | ||
$side = dynamic_sidebar(apply_filters( 'ups_sidebar', 'default-sidebar-id' ) ); | ||
if ($side !=null) | ||
|
||
echo '<h1>'.$side.' </h1>'; | ||
?> | ||
<?php while ( have_posts() ) : the_post(); ?> | ||
|
||
<?php get_template_part( 'content', 'page' ); ?> | ||
|
||
<?php | ||
// If comments are open or we have at least one comment, load up the comment template | ||
if ( comments_open() || '0' != get_comments_number() ) : | ||
comments_template(); | ||
endif; | ||
?> | ||
|
||
<?php endwhile; // end of the loop. ?> | ||
|
||
</main><!-- #main --> | ||
</div><!-- #primary --> | ||
</div> | ||
<?php | ||
if ( is_active_sidebar( $sidebar ) ) { | ||
echo '<div class="col-sm-3">'; | ||
dynamic_sidebar( $sidebar ); | ||
echo '</div>'; | ||
} ?> | ||
</div> | ||
<?php get_footer(); ?> | ||
<?php | ||
/** | ||
* The template for displaying all pages. | ||
* | ||
* This is the template that displays all pages by default. | ||
* Please note that this is the WordPress construct of pages | ||
* and that other 'pages' on your WordPress site will use a | ||
* different template. | ||
* | ||
* @package cornerstone | ||
*/ | ||
|
||
get_header(); ?> | ||
<h1>page.php</h1> | ||
<?php | ||
// sidebar custom field check. | ||
$sidebar = get_post_meta( get_the_ID(), 'uc_sidebar', true ); | ||
if( !is_active_sidebar( $sidebar ) ){ | ||
foreach(get_post_ancestors(get_the_ID()) as $ancestor){ | ||
$parent_sidebar = get_post_meta( $ancestor, 'uc_sidebar', true ); | ||
$parent_sidebar_children = get_post_meta( $ancestor, 'uc_sidebar_children', true ); | ||
if( is_active_sidebar( $parent_sidebar ) && $parent_sidebar_children != '' && $parent_sidebar_children ){ | ||
$sidebar = $parent_sidebar; | ||
break; | ||
} | ||
} | ||
} | ||
?> | ||
<div class="row"> | ||
<div class="col-sm-<?php echo (is_active_sidebar( $sidebar )?9:12); ?>"> | ||
<div id="primary" class="content-area"> | ||
<main id="main" class="site-main" role="main"> | ||
<h1>Sidebar?</h1> | ||
<?php | ||
$side = dynamic_sidebar(apply_filters( 'ups_sidebar', 'default-sidebar-id' ) ); | ||
if ($side !=null) | ||
|
||
echo '<h1>'.$side.' </h1>'; | ||
?> | ||
<?php while ( have_posts() ) : the_post(); ?> | ||
|
||
<?php get_template_part( 'content', 'page' ); ?> | ||
|
||
<?php | ||
// If comments are open or we have at least one comment, load up the comment template | ||
if ( comments_open() || '0' != get_comments_number() ) : | ||
comments_template(); | ||
endif; | ||
?> | ||
|
||
<?php endwhile; // end of the loop. ?> | ||
|
||
</main><!-- #main --> | ||
</div><!-- #primary --> | ||
</div> | ||
<?php | ||
if ( is_active_sidebar( $sidebar ) ) { | ||
echo '<div class="col-sm-3">'; | ||
dynamic_sidebar( $sidebar ); | ||
echo '</div>'; | ||
} ?> | ||
</div> | ||
<?php get_footer(); ?> |