Advertisement
Imperative-Ideas

Simplified page template based on conditional sidebar check

Jul 7th, 2014
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /**
  4.  * This code checks for a named active sidebar, then runs the appropriate template as a result
  5.  */
  6.  
  7. <?php get_header(); ?>
  8. <div class="wrap">
  9.     <section class="entry-content">
  10.  
  11.     <?php
  12.  
  13.         // Check to see if we have an active sidebar named "Primary"
  14.         if ( is_active_sidebar('primary')) :
  15.  
  16.             // Get the template "two-columns.php" inside of the "page-templates" folder and display its contents here
  17.  
  18.             get_template_part("page-templates/two", "columns");
  19.  
  20.         // No active sidebar?
  21.         else :
  22.  
  23.             // Get the template "one-column.php" inside of the "page-templates" folder and display its contents here
  24.             get_template_part("page-templates/one", "column");
  25.  
  26.         // End the conditional
  27.         endif;
  28.  
  29.     ?>
  30.  
  31.     </section>
  32. </div>
  33.  
  34. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement