Last active
August 29, 2015 14:09
-
-
Save aijodesigns/f767c1a33fd8b4e84fc5 to your computer and use it in GitHub Desktop.
(WordPress) Page Layout with Dynamic Sidebar based on Parent Page
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
<?php | |
/** | |
* Template Name: Page Layout | |
*/ | |
get_header(); ?> | |
<div id="main" class="row"><div class="container"> | |
<?php | |
$children = get_pages('child_of='.$post->ID); | |
$classes = get_body_class(); | |
if(count($children)!=0 || in_array('page-child',$classes) ) { | |
$contentClass = ' style=""'; | |
} else { | |
$contentClass = ' style="width:100%;"'; | |
} ?> | |
<div class="main-content col-md-9 pull-right" <?php echo $contentClass ?>> | |
<?php if (have_posts()) : ?> | |
<?php while (have_posts()) : the_post(); ?> | |
<h1><?php the_title(); ?></h1> | |
<?php the_content(); ?> | |
<?php endwhile; ?> | |
<?php else : ?> | |
<?php endif; ?> | |
</div> | |
<?php | |
if(count($children)!=0 || in_array('page-child',$classes) ) { | |
echo get_sidebar(); | |
} | |
?> | |
</div></div> <!-- #main --> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment