Welcome, guest!

Feel free to read the blog, browse for themes, or join the club.

Prefer editing templates over functions.php?

  1. You must be a logged-in exclusive member to view this reply.

  2. this is very cool for me Justin. Always learning new stuff from you. Very useful.

  3. I tend to break my functions.php up whenever it gets too unwieldly. If I'm making a bunch of changes to the singular content areas I'll have a file called functions_singular.php and then include that from functions.php.

    I should check some of my code though, and see if I can get away with only including it on pages that are required - I have a feeling I may not be doing that.

  4. Justin, could you give a simple example of a template file used here (misc-chunk.php), and, can php be added?

  5. You must be a logged-in exclusive member to view this reply.

  6. Man I think that it can save me from a lot of questions here in the forums :-) It seems like an easy way to hook stuff into my sites.

  7. Thanks for this. This is the single most confusing when coming from the 'old' way of coding to wordpress and functions.php. From this it seems we just use the locate_template as an include. And, doing it this way, we can add the conditional code to make sure we're not loading it everywhere. With this add_action and add_filter everywhere else, it seems the remaining challenge is just keeping all the mods organized so we know what is changing what.

    Thanks.

  8. I'm thinking of using this technique for getting Buddypress functionality into Hybrid - essentially stripping the functionality out of BP themes, creating a php file with the code and then using this technique to load it where appropriate. Assuming I also load the necessary css/js, should this work?

  9. Justin, this is great. Can you please tell me what I would have to add to limit the display of the "misc-chunk.php" to just one page?

    Thanks

  10. You must be a logged-in exclusive member to view this reply.

  11. Whoa!! Took a good look under the hood of BP1.2 and this is indeed going to be challenging. Don't this idea will help too much. I will post my ideas on the BP-specific thread.

  12. Does this method have any advantage over using a simple include and wrapping in a standard WP conditional function? It looks like it might combine the hook and include a bit more neatly, but you wouldn't be able reuse the code without stuffing your functions.php file full of these things., which would again, be redundant.

    With an include I'm able to nest the code chunks into folders and make things even cleaner. With this function, it just looks like WP searches first within the child theme folder for a template with the same name as the file in the parent theme folder. However, in your use case. it seems that this is simply behaving the same as an include.

    Does this add cause WP to recognize the custom template so that you can select it from the drop-down box on the "Write Post/Page" screen? I'm a bit confused, but am probably just missing the point. Must retire now.

    Thanks in advance.

  13. You must be a logged-in exclusive member to view this reply.

Reply

You must log in to post.

Limited Access

If you have an account, please take a moment to log in.

Non-exclusive members have limited access to the support forums.

To enjoy the full range of support, sign up for an exclusive membership in the theme club.

Support Forums

  • Bliss Theme (184 posts)
  • Hybrid Theme (16,884 posts)
  • Options Theme (10,321 posts)
  • Structure Theme (2,624 posts)
  • Visionary Theme (767 posts)
  • bbPress Themes (293 posts)
  • WordPress Plugins (1,615 posts)
  • General Discussion (3,911 posts)