How to integrate WP with your website?

By in Web Trends | 0 Comments

26 October 2010

WordPress is far more than a blogging platform. You can integrate WP to your entire website or to a particular page. It is not very tough to match WordPress with the look and feel of your website. By using this tutorial, you can easily do that.

Follow these steps to add WordPress posts in blog section of your website:

Creating Blog folder

Suppose we have a site named QuadraInstitute.com ( URL: http://www.quadrainstitute.com/ ).  Assuming that there is no blog section in the site, we shall create one such section. We shall go to the root of our site and create a sub-directory (folder) there named ‘blog’. So, the URL path of our blog section will be: http://www.quadrainstitute.com/blog

Adding PHP code Header

By the way, your site should be based on PHP pages because, WordPress codes are written in PHP. Two code snippets can be given that you have to place on top of each page:

Code Snippet 1:
<?php
/* comments goes here */

define('WP_USE_FLAG', false);               //define constant and its value

require_once('/wp-blog-header.php');                //include the file once

?>
Code Snippet 2:

<?php

require_once('path/wp-blog-header.php');            //include the file once

?>

Loop

WordPress has a way to display each of your blog post. This feature is called Loop. Whatever HTML or PHP code you add within the Loop, will be repeated for each page. The following things are generally written within a loop:

Title (title())

Time (time())

Categories (category())

Example of a really simple Loop for generating the WordPress posts into your blog page can be done with this code:

<?php
get_header();    // function for getting header function
if (is_posts()) : // whether comment is posted
while (have_posts()) : //if there is any post, then continue loop
the_post();
the_posted_content();        //posted message
endwhile;              //end the loop
endif;                    //end the if statement
get_sidebar();            //function for getting sidebar
get_footer();             //function for footer sidebar
?>

Generating a list

Now, we are going to generate a list with posted data, title and excerpt, you have to apply the following code:

<?php
Require_once('path/wp-blog-header.php');    //include the file once
?>
<?php
// code for generating a list with posted data, title and excerpt
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : start_wp(); ?>
<?php the_date(); echo "<br />"; ?>         //for date through loop function
<?php the_title(); ?>      //for title through loop function
<?php the_excerpt(); ?>   // for excerpt through loop function 
<?php
endforeach;
?>

For generating the last four posts on the list, you have to use this code snippet:

// Integrating the last four posts on your blog
<?php
Require_once('path/wp-blog-header.php');    //include the file once
?>
<?php query_posts('showposts=4'); ?>
<?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;?>

You will be amazed when four posts will be shown from WordPress to your blog. That is where we end now. Hope, you’ll face no problem putting these codes on your web page and to have WP posts integrated on your blog page.

Share and Enjoy

  • web trends wp socializer sprite mask 16px How to integrate WP with your website?
  • web trends wp socializer sprite mask 16px How to integrate WP with your website?
  • web trends wp socializer sprite mask 16px How to integrate WP with your website?
  • web trends wp socializer sprite mask 16px How to integrate WP with your website?
  • web trends wp socializer sprite mask 16px How to integrate WP with your website?
  • web trends wp socializer sprite mask 16px How to integrate WP with your website?
  • web trends wp socializer sprite mask 16px How to integrate WP with your website?
  • web trends wp socializer sprite mask 16px How to integrate WP with your website?