I tried reading the WordPress codex about integrating WordPress into an existing website.
I tried using the header information
<?php /* Short and sweet */ define('WP_USE_THEMES', false);
require('./wp-blog-header.php'); ?>
And then the test code
<?php // Get the last 3 posts.
global $post; $args = array( 'posts_per_page' => 3 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a><br />
<?php endforeach; ?>
Another code I added to make the page only for logged in users:
if ( ! is_user_logged_in() ) { // Display WordPress login form:
wp_login_form($args);
This code does make the login show, but when I log in, it cannot remember that it is logged in, and the functions (blog posts) will not show. The funny thing is, the login form (as called by the wp_login_form) shows, but I cannot log in. This is quite anoying, as the information in the codex doesn't work Integrating Wordpress with Your Website
It does not work. Can someone help me? I tried posting at the WordPress forum, but no help there
New edit 07th november: This is how the PHP file looks like now. It's called lite_index.php and includes the wp-load, and because of that I believe the login form under here shows, bt still it cannot login.
<?php
//define('WP_USE_THEMES', false);
//require('lite/wp-blog-header.php');
define('COOKIEPATH', '/');
require('lite/wp-load.php');
require('loggin_check.php');
//require(dirname(__FILE__) . 'lite/wp-load.php');
//header('Content-Type: text/html; charset=ISO-8859-1');
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : setup_postdata( $post ); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<?php
endforeach;
?>
<h1>Lite v4</h1>
<?php
if ( ! is_user_logged_in() ) { // Display WordPress login form:
wp_login_form($args);
} else {
wp_loginout(index.php); // Display "Log Out" link.
echo " | ";
wp_register('', ''); // Display "Site Admin" link.
echo "<br />\n";
}
?>
require('./wp-blog-header.php');
makes it look like that your WordPress-files are in the root-directory (amongst your other files). I think I would keep WordPress in a folder by itself, to avoid wierd collisions. I'm not sure if that's the right way to do it, though. ... Another thought that pops into my head is, that have you considered doing it the other way around (by putting your website into a theme, inside WordPress). I used to make websites like you describe, and it becomes a mess. But that's just my personal preference.