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

Gregory Lancaster greglancaster71 at gmail.com
Tue Aug 13 17:30:46 UTC 2013


Thank you, I can hardly believe how helpful people are here.  I am using
Roots framework, and I use post tags to associate posts with one another.
 So a group of related posts are all tagged "lightbulbs", which then a
sidebar code I wrote uses to grab all posts tagged with that and show them
in a sidebar style menu.  I opted for this over custom fields because you
can add and remove tags quickly from the quick edit menu, whereas with
custom fields you have to go in and manually edit every post to change
anything.  Although looking at what I am learning in this php class it
might have made more sense to just add the custom fields to the quick edit
screen.

Anyhow, so thats how the sidebar works.  The code I pasted above earlier is
for a left-sidebar used for gallery images and bootstrap scrollspy to show
people where they are on specific pages.  Thats why I need it to call based
on the post tag- so it shows along with the appropriate content.

Im not sure what else to share?  Knowing all that, is it still possible to
call the sidebar from one file with conditionals?


On Tue, Aug 13, 2013 at 5:37 AM, J.D. Grimes <jdg at codesymphony.co> wrote:

> > I am still learning php, so I apologize for the questions.  Can you
> point me
> > in the right direction to learn how to do this?
>
> Just create the sidebar template like you would have for one of the single
> tags, but instead of hard-coding things, make them dynamic. For example,
> where you would have put the tag name like "My Cool Tag", instead do
> something like this:
>
> <?php echo $tag->name; ?>
>
> You will need to get the tag, the same way that you are before you load
> the template. Or you may not need to get the tag at all until inside of the
> custom sidebar template (that depends on whether you know you are going to
> load that template before you check the post's tags).
>
> If you post an example of what you are trying to achieve, we can help you
> make it dynamic.
>
> - J.D.
> _______________________________________________
> 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