I am looking for a way to call in the recent posts from my blog on my site to the homepage of my site. The blog is wordpress and the site is html/php.
Any help would be much appreciated![]()
I am looking for a way to call in the recent posts from my blog on my site to the homepage of my site. The blog is wordpress and the site is html/php.
Any help would be much appreciated![]()
I use something like this:
PHP Code:<?php
$args=array('showposts'=>8,'caller_get_posts'=>1
);$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;}?>
That will only work if you are inside of wordpress. Functions like WP_Query and the_post only work inside of the wordpress installation.
I believe you need to include the wp-load.php file and a template referrence to make the above code work. The template referrence prevents the entire wordpress theme from loading and the wp-load.php file pulls in the wp-config and associated functions for wordpress.
put that code in the header section of the homepagePHP Code:define('WP_USE_THEMES', false);
require('./blog/wp-load.php'); //<---Change to your path to wp
Thanks guys, will get crackin on this![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks