[wp-hackers] Help with including custom templates using variables

Gregory Lancaster greglancaster71 at gmail.com
Thu Aug 15 19:33:31 UTC 2013


Im sorry, this is a wordpress theme so I am not sure how to post it on
github

My theme is Roots, its a bootstrap framework and makes use of a few files
to show the sidebars.
Here is the BASE.PHP which controls which files are loaded for sidebars.

<?php get_template_part('templates/head'); ?>
<body <?php body_class(); ?>>

  <!--[if lt IE 7]><div class="alert"><?php _e('You are using an
<strong>outdated</strong> browser. Please <a
href="http://browsehappy.com/">upgrade
your browser</a> to improve your experience.', 'roots');
?></div><![endif]-->

  <?php
    do_action('get_header');
    // Use Bootstrap's navbar if enabled in config.php
    if (current_theme_supports('bootstrap-top-navbar')) {
      get_template_part('templates/header-top-navbar');
    } else {
      get_template_part('templates/header');
    }
  ?>

  <div class="wrap container" role="document">
         <div class="content row">

         <div class="main <?php echo roots_main_class(); ?> " role="main">
        <?php include roots_template_path(); ?>
      </div><!-- /.main -->

         <aside class="left-sidebar <?php echo roots_left_sidebar_class();
?> " role="complementary">
    <?php if (roots_display_sidebar()) : ?>


    <!-- MY CODE TO PULL CUSTOM .PHP SIDEBAR WITH TAG IN FILENAME -->

<?php global $post;
$tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag);{
$tag_name = $tag->name;}
$end =  $tag_name;
?>

 <?php get_template_part('/templates/left-sidebar', $end); ?>
<?php else: ?>
    <?php endif; ?>
      </aside>

<!-- END OF MY CODE -->

      <aside class="sidebar <?php echo roots_sidebar_class(); ?>"
role="complementary">
      <?php if (roots_display_sidebar()) : ?>
        <?php include roots_sidebar_path(); ?>
      <?php endif; ?>
      </aside><!-- /.sidebar -->

 </div><!-- /.content -->
  </div><!-- /.wrap -->

  <?php get_template_part('templates/footer'); ?>

</body>
</html>



The actual left sidebar has nothing in it, just some static content I want
to display on specific posts with this tag.   So how would I go about
altering that code?  Should I put this code within left-sidebar.php?



On Wed, Aug 14, 2013 at 3:47 PM, J.D. Grimes <jdg at codesymphony.co> wrote:

> Have you already created the code that displays all the posts for a tag?
> In other words, have you already written one of the custom sidebars? If so,
> could you post that code?
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list