The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Show new posts outside wordpress (2 posts)

  1. fermars
    Posted 7 years ago #

    Hello, I have two WordPress installed on my server and I want to show the latest posts added to them on a webpage outside the WordPress directories, using include function. This is the code (pointing to "directory" 1 or 2 depending on what wordpress you want to call):

    <?php require_once("directory/wp-config.php"); ?>
        <?php $my_query = new WP_Query('showposts=4');
     while ($my_query->have_posts()) : $my_query->the_post();
          $do_not_duplicate = $post->ID;?>
        <a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
        <?php the_time('j \d\e F \d\e Y'); ?><br />
     <?php endwhile; ?>

    What I do is duplicate this code to try to show the new posts separatedly but the problem is that when you load the webpage, both codes shows the same posts. This is like the variables load with the first code and it is maintained on the second load of code. I hope to have explained it well.

    Any ideas?
    Thank you.

  2. moshu
    Posted 7 years ago #

    Why not use RSS feeds instead?

Topic Closed

This topic has been closed to new replies.

About this Topic