WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Hack: Get WordPress Page outside of install (3 posts)

  1. marcy_sss
    Member
    Posted 4 years ago #

    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>
  2. MichaelH
    Member
    Posted 4 years ago #

    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>
  3. marcy_sss
    Member
    Posted 4 years ago #

    Dude! That totally works! Thanks a million :D

Topic Closed

This topic has been closed to new replies.

About this Topic