Integrating WordPress Within My Site
My goal was to incorporate WordPress blog functionality within my existing site.
These are useful resources in understanding how WordPress works:
- How WordPress works – an infographic from Yoast
- WordPress theme development from the WordPress.org site
- Integrating WordPress within Your Website – from the WordPress Support section
WordPress Installation and Theme Change
These are the steps to install WordPress and create a new theme, containing any relevant resource links.
- WordPress installation
- In the new WordPress installation I created a new directory within the themes/wp-content directory. I gave this directory the name of new theme.
- I created style.css within new theme directory. This does require a mandatory comment header for WordPress to identify the theme – see theme stylesheet directions.
- Then I changed to my theme within WordPress
At this point the WordPress installation presented a blank page as the templates had yet to be created.
This site uses WordPress post functionality, anonymous commenting and the blog search functionality. The WordPress theme development page contains a list of templates files that can be updated and included. These are the templates I customised for this blog.
- index.php – template for the home page of the blog. See Theme Development – index.php.
- single.php – template to display single posts. See Theme Development – single.php.
- comments.php – specifying how comments and the comments form will be displayed. See Function Reference/comments template.
- search.php – customising the search page and how search results are displayed. See Creating a Search Page.
- searchform.php – to customise the search form. See Function Reference/get search form.
- functions.php – to change default behaviour of WordPress. See Functions Explained. My file removes code that was causing any page containing the category list not to validate. See Make your WordPress category list valid by removing the “rel” attribute.
- 404.php – when a post cannot be found through a broken link. See Creating an Error 404 Page.
- For the pages including a categories list I replaced the get_categories function with the get_the_category_list function for more control over the code produced.
Incorporating Site Features on Blog Pages
I had already used PHP includes for the header, footer and navigation of my basic site and these were included in the template pages.
Post Update – 11th September 2013
I used the following HTML5 time element with WordPress functions for the post date.
<time datetime="<?php the_time('Y-m-d') ?>"><?php the_time(get_option('date_format')); ?></time>
To include the date in a format required by the
datetime attribute involved the use of the WordPress PHP function
thetime() rather than
thedate() as the latter only works once for posts published on the same date.