I’m running a website with modx but the client’s blog is a wordpress site. I’d like to integrate the latest blog post title, date & excerpt onto a modx home page. However it doesn’t seem to work in the normal way in which I’ve done it with non modx sites (see below). I’ve tried integrating it into a snippet but this still doesn’t work. Has anyone managed to get this to work before?
// 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>
<?php endwhile;?>
don’t know if this does work, but I would try it this way in your snippet:
<?php
// Get the last 3 posts.
require('/the/path/to/your/wp-blog-header.php');
query_posts('showposts=3');
while (have_posts()) : the_post();
$out .= '<a href="'.the_permalink().'" rel="bookmark" title="Permanent Link to'.the_title().'">'.the_title().'</a><br />';
endwhile;
return $out;
-
☆ A M B ☆
- 3,141 Posts
I don’t see a reason that would be redirecting, unless the wp-blog-header.php file has some sort of check to make sure it’s within wordpress, but I don’t think that should be the case?
If you open up firebug or something similar while loading, you can see the redirects in action and see where to/from it is trying to send you. One culprit is often the htaccess file if any modifications were made there...
A simple solution might be to use the getFeed snippet. Set the rss feed of your wordpress blog to output a summary, (in Settings->Reading). Then use getFeed to pull the latest post with title, author, excerpt etc into your MODx site.