','</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. "> ','</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. ">
Technology

Sprucing up

Opinion

Cooking

Opinion

Space Degree

Opinion

Relaxation

Technology

Round Pebbles

Sillyness Spelled Wrong Intentionally

Adding Wordpress to an existing Site

Adding Wordpress to an existing Site was penned 12 years ago. It was was spinning on the ol' iTunes.


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.

I hope you enjoyed reading Adding Wordpress to an existing Site
By becoming a Patron of Sillyness you can ensure quality writing, film, photography and music like this continue to be made available.