We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23428
    • 27 Posts
    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;?>
      • 4172
      • 5,888 Posts
      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;

        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 23428
        • 27 Posts
        thanks for the reply. it doesn’t seem to like the path i’m saying the file is in. on my system it’s http://www.theurl.co.uk/blog/wp-blog-header.php but it doesn’t seem to allow the url so removed that and just tried /blog/wp-blog-header.php but it doesn’t like that either saying it can’t find it. not quite sure what the path should be; any ideas? undecided
          • 23428
          • 27 Posts
          hmm thanks for that ganeshXL. i think i’ve found the right path but now the site comes up with and error:

          Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

          anyone know if i can do anything about that??? huh
            • 18373 ☆ 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...
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 8609
              • 607 Posts
              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.