As I mentioned in my previous post, I have very little experience with WordPress, and I am just getting started. This post consists of a few notes that I have learned so far (admittedly it's not much!)

Wordpress themes are stored under wp-content/themes (relative to your apache doc root, usually /var/www/html). The idea, like with most CMS, is to provide a blockwise way to build templates (c.f. Mezzanine for Django). You make a footer.php and a header.php for example, and then in the template you are building you can include them simply by calling a built-in function like:

<?php get_header() ?>

wherever you want them to appear.

Templates: Wordpress has a default template, page.php. When a user wants to add a new simple page (perhaps he has the freedom to edit a text area in the center of the page say, but the rest of the page content, like header, sidebar and footer remain the same), the chances are that he will want to select the default template in the wp-admin, and this will mean he creates a page based on the page.php of the theme. This template can be styled however you want your default pages to look, but usually would have at least

<!-- page-content -->
<div class="page-content">
    <?php the_content() ?>
    <?php wp_link_pages() ?>
 <!-- ENDS page-content -->

wherever you want the content a user has written in the admin to appear.

You can also create custom templates in WordPress. For example let's say you wanted a template for just the front page, then you could create a template called front.php and add

Template name: Front 

to the head followed by the rest of your static HTML. Now add a new page in the admin called "Home" and from the page attributes select our Front template. In Settings>Reading, change the "Front page displays" option to static page and select the page as "Home" and voila!

Contact form

Obviously this is a very common requirement, and I found the contact-form-7 plugin really useful. It allowed me to tweak the fields, the email sent to the admin and the user without even touching the backend code. It generates a handy "shortcode" that a user can just embed in the text that they are adding to a given page in the admin.

One issue I had was how to embed a form created by contact-form-7 to my static front page template? I found the easiest way was the snippet

        <?php echo do_shortcode("[contact-form-7 id='35' title='Application Form 1']"); ?>

which runs the shortcode in the template, handy...

Other files of interest

I guess the main other file I stumbled across was functions.php, in which you can define your own custom php functions, and set handy variables like $themePath = get_bloginfo('template_url') . "/"; that you could use when adding your css files for example.

OK, not exactly rocking the WordPress knowledge foundations with this post, but hopefully it will jog my memory if I ever come to work with WordPress in more depth in the future...

Currently unrated

About Lee

I am a Theoretical Physics PhD graduate now working in the technology sector. I have strong mathematical skills and originally started in heavy-duty scientific computing, but now I work mostly with Python and the Django framework. I am available for hire now, so check out my resume and get in touch.