Introduction
By nature, WordPress is very powerful. It can be as complex or as simple as you wish. With that in mind, how much you want to use WordPress with your existing website is totally up to you. There may be only a few features of WordPress you want to use when integrating it with your site, or you may want your entire site run with WordPress. This tutorial will guide you through making your WordPress site look like your current design. We will start with how to make a WordPress blog look like the rest of your site. Then we can move on to making your entire site running on WordPress.
Begin the transformation
First, assume you have an existing site at http://myexample.com. Next, create a new sub-directory (folder) at your site and call it ‘blog’ (you could use something other than blog, but you must create this sub-directory). So you now have an empty sub-directory at http://myexample.com/blog/. Now, download WordPress and upload all of its files into this new folder, and install WordPress.
Grab the header
In order to transform regular PHP pages into ones that utilize WordPress, you need to add either of the following code snippets to the start of each page.
<?php /* Short and sweet */ define('WP_USE_THEMES', false); require('./wp-blog-header.php'); ?>
<?php require('/the/path/to/your/wp-blog-header.php'); ?>
The Loop
It is necessary to include The Loop in your pages to effectively take advantage of the multitude of Template Tags or plugins available. Familiarize yourself with The Loop and the basics of The Loop in Action to get underway with integrating the power of WordPress into your website.
Examples
Generate a list
In the event you want to show ten posts sorted alphabetically in ascending order on your web page, you could do the following to grab the posted date, title and excerpt:
<?php require('/the/path/to/your/wp-blog-header.php'); ?> <?php $posts = get_posts('numberposts=10&order=ASC&orderby=post_title'); foreach ($posts as $post) : start_wp(); ?> <?php the_date(); echo "<br />"; ?> <?php the_title(); ?> <?php the_excerpt(); ?> <?php endforeach; ?>
Last three posts
Display the last three posts on your web page.
// Get the last 3 posts. <?php require('/the/path/to/your/wp-blog-header.php'); ?> <?php query_posts('showposts=3'); ?> <?php while (have_posts()) : the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a><br /> <?php endwhile;?>
No comments:
Post a Comment