Soon after I started the Founding Father posts, I wanted a way to put a little blurb on each post but I did not want to retype this blurb every time. PHP include to the rescue! PHP is the programing language that my WordPress blog is based on and it has a standard function call “include” that accomplishes exactly what I need.
Initial setup for using PHP
I use the Atahualpa Theme. PHP execution is not enabled automatically. My first step was to find a WorpPress Plugin that allows for PHP execution within my blog posts. I decided on the PHP Execution plugin. There were other plugins but this one was well rated and works with the Visual Editor. Once the plugin was installed and activated I was ready to try my include.
How I use PHP Include
The basic syntax for PHP include is:
<?php include("file-name.php"); ?>
The “file-name.php” can be any text file that is uploaded to your blog site. For my Founding Father posts i named this file “inmessment-ff-blurb.php”. The text in the file I use right now is the following HTML code:
<div class="inmess-highlight-box-blue">
<h3>Founding Fathers Post</h3>
This is an inMessment <a href="http://www.inmessment.com/category/freedom/">Founding Fathers</a> Post. My plan over time is to add posts for each of the 56 signers of the Declaration of Independence. I appreciate comments, questions or suggestions!
</div>
Then in each Founding Father post I do not have to retype that little blurb. All i have to do is insert the line, <?php include("inmessment-ff-blurb.php"); ?>, in the HTML editor for the post and then that line is replaced with the contents of the file. I can also use it in the “Excerpt” for my posts which show on the inMessment home page.
For the box below I put the following text in the HTML editor for this post, <blockquote><?php include("inmessment-ff-blurb.php"); ?></blockquote>, which results in a section that looks like the following:
inMessment Founding Fathers Posts Have Moved:
This Post will redirect to HistoricWords.com
Follow this link for more details.
In the future if I want to change the blurb, all I have to do is change the text in the inmessment-ff-blurb.php file and the PHP include function will dynamically update all my posts with the new information the next time the posts are displayed.
It is that simple. I hope this helps. I have made a lot of assumptions about website and HTML experience for my readers. Please comment any questions and I will do my best to answer them.



