Reputation: 39
Please provide the code for how to integrate. I kept blog inside at public_html folder and blog has one database and site has other database I have created.
I have tried these code at my site index.php
<?php require('blog/wp-blog-header.php');?>
<?php
$args = array( 'numberposts' => 2, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post); ?>
<div class="events">
<p><strong><?php the_date(); ?></strong></p>
<p><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></p>
</div>
<?php endforeach; ?>
but shows an error like
Fatal error: Call to undefined function wp_get_recent_posts() in
/home/sharelok/public_html/application/views/index.php on line 124
Upvotes: 1
Views: 2117
Reputation: 146191
You may try this
define('WP_USE_THEMES', false);
require('blog/wp-load.php');
$postslist = get_posts( array( 'posts_per_page' => 2, 'orderby'=> 'post_date' ) );
foreach( $postslist as $post ) : setup_postdata($post); ?>
<div class="events">
<p><strong><?php the_date(); ?></strong></p>
<p><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></p>
</div>
<?php endforeach; ?>
Upvotes: 1