WordPress Fundamentals for Newbies

Lot of times I get messages in my inbox about simple WordPress questions like how to configure a certain plugin to work with a certain theme so that gave me an idea to write an article about WordPress fundamentals (for newbies).

I made a quick sketch in Paint, of what I feel is a diagram of  whole fundamental inner workings of a WordPress blog.

wpflow

Basically it means that WordPress consists of three elements: WordPress core, plugins and themes. These elements can interact between each other producing final output visible by the end user.

Theme will by default get information from WordPress core, like blog name, URL of the current page, post content, comments etc. It will then display it using PHP functions embedded into the theme. When you see '<?php the_content() ?>' in your theme, you are looking at an example of one such PHP function.

However you can also install plugins to your blog. In most cases plugins will also want to output something to the world.

And basically there are two main ways plugins can do this. They can use (their own, special)  PHP functions too like themes, or they can hook to WordPress actions and filters.

Actions and filter hooks are events that get triggered at certain point of time and which the programmer can use to take incoming information, modify it and pass it on.

For example there is a filter called 'the_content' (same name as the function previously mentioned) which allows the programmer to change the content of the post on the fly, and show the modified version on the blog.

And this is the main point I think most people have trouble figuring out.

Let's take for example Similar Posts plugin, which will add a useful list of related articles after the post.

The plugin documentation states you can enable this functionality in two ways. You can edit the theme and add

<?php the_content(); ?>

// insert similar posts now

<?php similar_posts() ?>

line just after 'the_content()' line in your theme. Or in the plugin settings, you can decide that the plugin will automatically add related articles to the end of post (by using the 'the_content' filter to automatically hook into the the_content and show related posts at the end).

The end result is in most cases identical. It isn't in the case when there are several plugins hooking to the_content filter, so your related articles might not be the very last to display. But when you call the plugin function directly below the_content() call in the template file, it is guranteed to display after all content.

So this was a quick surge of thoughts, I hope it has helped someone. Tell me what else would you like to read about.


More like this:


Posted in: WordPress
TAGS:, , , , , , , , , , , , , , , ,
Both comments and trackbacks are currently closed.

4 Comments

  1. Feb 13th, 2009

    Mate, you're a source of so much knowledge!
    It's a really great pleasure to read your posts.
    I just liked to say thanks for sharing your knowledge
    Cheers
    Lucio Ribeiro

  2. Feb 11th, 2009

    Thanks for the info. Any insight on how to add or enable the use of excerpts on themes that currently don't support it. I have tried multiple times to enable excerpts using the tag and I have had no luck. I have done pretty extensive research but nothing seems to solve the issue.

  3. Feb 10th, 2009

    Thanks for describing WordPress, themes and plugins in an easy manner for newbies to understand.

  4. Feb 10th, 2009

    Please approve my thread

    http://www.prelovac.com/vladimir/forum/amazing-grace/may-be-a-problem-with-centered-images?value=hardeep%25251&search=1

    on the forums. I was able to fix the issue on my own blog http://blog.hardeep.name though - however, I would like to do it 'the right way'.

  • ManageWP