more »
Well it is time again for everyones favorite series. So far we have covered some pretty groovy stuff. Part 1 showed us how to create custom code laden templates that can be applied to blank pages in WP to achieve some gnarly effects.
In Part 2 we talked about creating custom templates for each of your categories, opening up a whole world of possibilities. Today we are going to talk about a little used theme template, the Home Template (home.php).
There is now a little more than a month till drbacchus and I leave for Stuttgart and ApacheCon Europe.
I am pretty stoked, and a little nervous to tell you the truth. I can talk all day about this stuff don’t get me wrong, but I really want this to be the first of many such trips and in many ways that all hinges on this appearance.
Well nothing to do about it now, I have written what I think will be a good session, and I can only go and do the best I can, hoping to have a good group.
And let me tell you, my Flickr Pro Account (thanks skippy!) will be blowing up while I am there.
more »
When last we met we talked about Using custom templates to add pages to WP that don’t necessarily call for posts or categories, etc. Today we continue our exploration of custom templates by looking at another little known power hidden within the theme system: Per Category templates.
more »
Today I am beginning a series on some of the lesser known features of the Theme System in WordPress 1.5 , I am not sure how many parts there will be, might be just this one. But don’t count on it. Here are Part 2 and Part 3.
So lets talk about Custom Templates, and more importantly how we can bend them to our will. Now I am assuming that by now everyone has at least a passing familiarity with Templates in WP 1.5, for those who are not up-to-speed, lets cover some back-story.
more »
I have mentioned themes briefly before, but in light of some questions I have been fielding I have decided to dedicate some time to a proper tutorial. Hopefully we can flesh this out a bit more fully, just remember the mantra: “We write the theme, We love the theme, We are the theme.”
Now we comes the part where we throw in some cache-action. Brought to you by the Dynamic Duo Mattman and Zeller the Boy Wonder. Now Staticize Reloaded is not the best thing since sliced bread, but it is pretty great regardless.
Now I am not going to get into the “how” the plugin works, I mean who wants that! We are Americans, we just want it to work now! So anywhoo, follow these easy steps to set up a little cache action:
Okay so now we have our pseudo-static sections caching (as well as our non-pseudo-static sections), so what is the next weapon to add to our arsenal? Read on and find out.
The next part of this tutorial requires you to be able to make changes to your apache setup, either through editing of httpd.conf or through .htaccess. Sooo… if you can’t do one of these two things, please skip on to page 3. Those of you still with me, lets get to the hackin! What we are trying to accomplish here is to add some flare to our newly created and cached sections. Most sites that have aboutme and colophon sections use a site uri something like this: mysite/colophon/, now our solution poses a problem since they are not files in sub-domains, they are php files residing in our $siteroot, or wp directory. There are two ways to approach this:
So, what we need to do is fire up the old terminal and edit either httpd.conf or .htaccess. I will let you find out where these files are located since each distro handles placement differently. For this haxie we simply need to add this snippet of code:<Directory /home/www/sitename/htdocs>Options + MultiViewsto your httpd.conf file or your .htaccess and then once saved, restart apache. I prefer the lovely:
</Directory>apachectl gracefulcommand to restart apache, since it politely kills the child processes instead of just hacking them off wholesale. ; Now there could be a performance impact by doing the above, but unless you are running with a couple million hits a day, it is minimal.
Okay now we have our site running without file extensions, and caching. So what is left? Good question, to close I wanted to suggest some cosmetic changes. On our pages like aboutme and colophon, we really don’t want to have people leave comments, and we don’t really need to display the time, day, category and author for each of these “entries” so we should get rid of those function calls. Keep in mind that what we might want is a last updated on bit of code, that would find the date and time for the newest entry on that cat and echo it out.
That can be accomplished by using a bit of custom code, or by exploiting some of the functions already built into WordPress. That my friends is your homework. Well that is it for now, let me know if there is anything else you would like to hear on this topic, or if anything I have stated is not as clear as it could be.
Cheers.
more »
Part two is now up, you can find it over here. This series is by no means exhaustive, but it is a good place to begin to understand customizing WordPress. NOTE: This tutorial only covers WordPress 1.2, if you are running WordPress 2.0 this is all useless.
In this tutorial we will cover the steps necessary to use WordPress as a CMS. This tutorial will cover the basic concepts and steps to get something up and running as quickly as possible, part 2 will cover more advanced tricks to get the most out of your WPCMS.
The first step is to identify exactly what you want to get out of a CMS, just because you can make WordPress function as a CMS doesn’t mean you should. Be sure before you begin that you are not creating more work for yourself than neccessary.
Okay so I assume since you are still with me that you have decided that a WPCMS is for you. Now, we need to identify how your new shiny sight will be organized. For the purposes of this tutorial lets assume that you will have the following site structure:
Over at the WordPress Support Forums a user asked how he/she could incorporate WP into thier existing site.
That prompted me to finally get around to writing some tutorials on WP, and how to better integrate it into your existing site.
So here is the first installment. Basically you can think of WP as a collection of functions or scripts that do specific things. If you want to have your site title to be somewhere on the page, you simply type in:<?php bloginfo('name'); ?>This piece of code is all that is required on your part to achieve the desired affect.
So let’s get down to brass tacks. Say you have a site all ready to go, and you only want to use WP to power the text of your site; that is easy enough to do.
First lets set the stage. For this example we will assume you have the following DIV’s defined in your CSS:
First you need to add this to the top of your index page:<?php $blog = 1; require('wp-blog-header.php'); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">I am assuming that you are using XHTML 1.1 here, I mean isn’t everyone? The <?php… line is required for WP to function.
<html xmlns="http://www.w3.org/1999/xhtml">
Now, within the .content DIV add these functions:<?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>This is the “motor” that starts WP off pulling your content from the database. Alright next you would add this: <?php the_date('','<h2>','</h2>'); ?>Then one of these:<a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a>Now this bit of code calls to the database and grabs the title of your post, the way it is set up here is to make the title your permalink; a permalink is the permanent URI of this article. I f you don’t want it to be a link, leave off all the <a href=”“></a> code.
Okay so far we have the date and the post title showing up in the .content DIV, now on to the actual post content.
Next we want to throw this function in:<?php the_content(); ?>That will call the body of your post and spit it out in the .content DIV. Pretty straightforward huh? Now we move onto the meta information, i.e. the category it was posted in (if any), the author who posted it (if you have more than one, or just like to see your name in lights), the time it was posted, and a link to any comments for that post. Here is the function code to make that happen:<?php link_pages("<br />Pages: ","<br />","number"); ?> :: <?php the_category(); ?> :: <?php the_author(); ?> @ <a href="<?php echo get_permalink(); ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_time(); ?> :: </a> <?php show_post_count($post->ID, $before="Read Count (", $after=")"); ?> <?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)'); ?>This will spit out the appropriate values looking something like this:
Pages: (if multiple pages for post) :: TheCategory :: Mr Author @ 4:44 PM/AM :: Comments (0)
Next you need to add this code immediately after the above:<?php include('wp-comments.php'); ?><?php if ($p > 0) { add_count($p);}?><?php endforeach; else: ?><p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?></code>
That is all there is too it really, except that you will have to save this page with a .php extension(added 05.10.2004). Now you will obviously want to style these, and add some sort of seperation between functions, like <br />'s or throwing each funciton in it's own DIV nested within the .content DIV, it is really all up to you.
Let me know if this was helpful and if so, what other tutorials you would like to see on WP in the future.