Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm creating a template, and one of the files is getting overloaded with pig-ugly mixed html and php.

At first I thought that maybe I should cut out chunks of the code, and call them using include().

Then I thought - maybe there is a wordpress way to do things. Perhaps I should abstract out my logic from the templates, by putting the custom loop in functions.php, and then calling it somehow from the template.

How do I do this?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

This is personal preference and there are many ways it can be done. I like to keep my templates as clean as possible and use get_template_part() to include the various parts.

For parts of code that is used often I like to create functions and call the functions in the templates.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.