the entry post type
more »

Secrets of WP Theming: Part 3

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).

Read the rest »

June 13, 2005 35 Comments
the entry post type

Almost go time

There is now a little more than a month till drbacchus and I leave for Stuttgart and ApacheCon Europe.

So here’s the lowdown

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.

June 6, 2005 9 Comments
the entry post type
more »

Secrets of WP Theming: Part 2

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.

Read the rest »

June 2, 2005 41 Comments
the entry post type
more »

Secrets of WP Theming: Part 1

Featured Article on the 9rules network

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.

Read the rest »

May 26, 2005 124 Comments
the entry post type
more »

Much ado about themes

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.”

cjd_word_count();

Read the rest »

January 20, 2005 10 Comments
the entry post type

Faking it: WordPress as CMS pt. 2

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:

  • I assume you have followed the above link and downloaded the plugin from Matt’s site?  Well if not then go and download away, I will wait.  Done?  Good.
  • Now, you want to drop that badboy into your /plugins/ directory located within the /wp-content/ directory.
  • While you are in the /wp-content/ dir, go ahead and create another dir called cache within /wp-content/ and make sure to chmod, or set permissions to 777.
  • Now login to your admin area and go to plugins, you will now see Staticize Reloaded listed, go ahead and activate it.
That is it, the plugin performs all its tasks behind the scenes.  One caveat, you must deselect gzip compression from the “reading” screen of your options, this is being worked on and should no longer be a factor in the near future.  If you leave it selected it will bork the whole process.

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:

  1. Create folders for each section, and move the files we created earlier into them, making sure to either a.) make symlinks from $siteroot to the corresponding files in thier sub-directories, or b.) edit each of our pages to point to one directory up, e.g. ../wp-blog-header.php instead of wp-blog-header.php.
  2. Or we could perfom some apache magic and eliminate the need for file extensions.  What this gives you is the ability to input say mysite.com/index and have it resolve to index.php.  This also means that if you type in mysite.com/colophon/ it will resolve, no questions asked to mysite.com/colophon.php without updating the URI field.  I think you can see where I am going with this, and the possibilities that this presents.
Also, you can congratulate yourself for being forward thinking.  Eventually everyone will wake up and realize that running your server this way is better for the user.  With this method I could easily move from using php to power my site to cgi or asp (not that I would want to) and my users would never know, and more importantly thier bookmarks and permalinks would not break since they were pointing to chrisjdavis.org/index.

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 + MultiViews
</Directory>
to your httpd.conf file or your .htaccess and then once saved, restart apache.  I prefer the lovely: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.

July 24, 2004 2 Comments
the entry post type
more »

Faking it: WordPress as CMS pt. 1

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:

  1. index/home page
  2. colophon/information page
  3. about me/about us page
  4. movie/music reviews
We all set?  Good lets get going.

Read the rest »

July 15, 2004 47 Comments
the entry post type

Adding Wordpress to an existing Site

I have updated the tutorial with some important pieces of information that had been left out originally.  It is much more complete now.

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:

  1. .header
  2. .menu
  3. .content
  4. .footer
Now all we will be concerned with in regards to WP is the .content DIV.  Here is where you will need to insert your functions.  I am going to assume that one would like to have the date, category, author name, time and comments in the .content area, following is how you would do that.

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">
<html xmlns="http://www.w3.org/1999/xhtml">
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.

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.

May 7, 2004 28 Comments
 1 2 3 … 6 Next →