0

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?

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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