This demonstration series will show you how you can create and include a ‘functions.php’ external file to your Project1 template.
Specifically, you will learn how to create and implement a script as a user-defined function that dynamically names the following on all the pages:
- the banner area’s <h2></h2>
- a class/ID name to be used wherever you wish
- <img> source file and its alt text
You will see how to implement it by declaring the function in an external ‘functions.php’ file, including the ‘functions.php’ file inside the ‘head.inc.php’ file, and also calling the function inside the ‘head.inc.php’ file so that you can use its global scope variables anywhere within the template’s component pages.
Lastly, the demo also explains the difference between echoing the function’s results vs. using the stored variable values generated by a function from an external include() page.
The following is a 3-video playlist. To jump to a specific video, click the top left video player icon to access the list.
Project 1 – Adding a Page Naming Function