SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jun 2006
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Query content using pageid

    Hi Folks,

    I'm having the devil of a time trying to get this simple page setup, I'd really appreciate some help and advice.

    I'm trying to point my tabs and custom app facebook pages to wordpress pages, which I'm told can be done.

    My facebook page can then pull in the content from wordpress, and this would save me having to update 2 seperate sites.

    Basically, can someone please tell me how I can hardcode the page id into each query, so If I browse to my about.php page in wordpress it displays the title and content from the about page, without all the html from my original wordpress theme.

    I've tried some code like below

    <?php
    $page_id = 147; // page id of about page
    $page_data = get_page( $page_id );
    $content = apply_filters('the_content', $page_data->post_content);
    $title = $page_data->post_title;
    echo $content; //
    ?>

    but I get the error:

    Call to undefined function get_page()

    Can anyone please help, this must be possible I'm sure it can be done somehow.

    Many thanks in advance, any advice and code samples much appreciated.

  2. #2
    SitePoint Addict
    Join Date
    Jun 2006
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cracked it

    <?php
    // Include WordPress
    define('WP_USE_THEMES', false);
    //exact path for wp-load.php.
    // This file is kept in the root of wordpress install
    require('wp-load.php');
    //Query wordpress for latest 4 posts
    query_posts('page_id=127');



    ?>
    <?php while (have_posts ()): the_post(); ?>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>

    <?php endwhile; ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •