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.

  14. What if I want to put all these php files into a separate folder, so when updating they don't get deleted (I know I could put this in the child theme folder, but let's say I just wanted to keep that folder intact (apart from the lines of code I had added to functions.php))?

    Say I would like them to be in wp-content/custom-code

    And are there any disadvantages to this?

  15. Template-related functions in WordPress are more complex than straight include. They know distinction between child and parent theme, will try parent if template not found in child, etc.

    Basically disadvantage is throwing all that out of the window. There is no reason to in context of WP. And outside of that (like including some very unrelated code) it's specifics that matter.

  16. 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

  • Core Framework (54 posts)
  • Hybrid Theme (22,711 posts)
  • Bliss Theme (255 posts)
  • Options Theme (10,362 posts)
  • Visionary Theme (767 posts)
  • WordPress (144 posts)
  • WordPress Plugins (2,146 posts)
  • bbPress Themes (308 posts)
  • General Discussion (5,572 posts)
  • Critical Theme (0 posts)
  • Hybrid News Theme (132 posts)
  • Hybrid Original Theme (26 posts)
  • Leviathan Theme (16 posts)
  • Life Collage Theme (9 posts)
  • Old School Theme (3 posts)
  • Outline Theme (108 posts)
  • Skeleton Theme (40 posts)
  • Structure Theme (2,768 posts)
  • Members Plugin (2 posts)
  • Cleaner Gallery Plugin (14 posts)
  • Get the Image Plugin (3 posts)
  • Message Board Plugin (0 posts)
  • Widgets Reloaded Plugin (0 posts)
  • Breadcrumb Trail Plugin (0 posts)
  • Query Posts Plugin (80 posts)
  • Hybrid Hook Plugin (7 posts)
  • Hybrid Hook Widgets Plugin (0 posts)
  • Hybrid Tabs (5 posts)