Support » Plugins and Hacks » Hack: Get WordPress Page outside of install

  • Resolved marcy_sss

    (@marcy_sss)


    Hi There!

    I have successfully grabbed posts outside of WordPress before by including wp-blog-header.php, but this time I am trying to grab a specific WordPress Page. So far I haven’t found a way to get a specific page_ID outside of the application. Any suggestions?

    //Header include
    <?php
    define('WP_USE_THEMES', false);
    require('./blog/wp-blog-header.php');
    ?>
    // Content will follow in body of html document - below is
    // what I used to get posts (modified). I need a PAGE this time.
    <div id="pressContent">
    	<?php $args1 = array('page_ID=20');
    	      query_posts($args1);
    	      $posts = get_posts('page_ID=20');
            foreach ($posts as $post) : start_wp(); ?>
    	   <p><?= $the_content(); ?></p>
    	<?php endforeach; ?>
    </div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Probably could just change this:

    <div id="pressContent">
    	<?php $args1 = array('page_ID=20');
    	      query_posts($args1);
    	      $posts = get_posts('page_ID=20');
            foreach ($posts as $post) : start_wp(); ?>
    	   <p><?= $the_content(); ?></p>
    	<?php endforeach; ?>
    </div>

    to

    <div id="pressContent">
    <?php
    $args1 = array(
      'page_id'=> '2'
    );
    $posts = get_posts($args1);
    if ($posts) {
      foreach ($posts as $post) {
        setup_postdata($post); ?>
        <p><?php the_content(); ?></p>
      <?php }
    }
    ?>
    </div>

    Dude! That totally works! Thanks a million 😀

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hack: Get WordPress Page outside of install’ is closed to new replies.