WordPress.org

Ready to get started?Download WordPress

Forums

adding wordpress page to another html site (5 posts)

  1. zvenson
    Member
    Posted 4 years ago #

    Hi Community!
    I want to do the following but didn`t find a propper solution yet:
    I have a static html site as my homepage and have a working wordpress blog installed on the same server.
    I need to "embedd" some of my wordpress pages to the static html site - i managed to include the blog posts to my site by adding this to my static html site:

    <p><?php
    // turn off WordPress themes and include the WordPress core:
    define('WP_USE_THEMES', false);
    require($_SERVER['DOCUMENT_ROOT'] . 'test/wp/wp-blog-header.php');
    ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="post" id="post-<?php the_ID(); ?>">
    <h2 style="margin-bottom:4px">
    <?php the_title(); ?>
    </h2>
    <hr style="margin-top:0px;margin-bottom:0px;padding-right:10px;" noshade="1" >
    
    <div style="color:#ddd" class="postmetadata">
    <?php df_get_postmetadata( array( "date", "author"), 'span' ); ?>
    </div>
    
    <div style="padding-right:10px" class="entry">
    <?php the_content(); ?>
    </div>
    
    <div class="postmetadata">
    <?php df_get_postmetadata( array( "tag", "edit" ), 'span' ); ?>
    </div>
    
    </div><!-- end of post -->
    
    <?php endwhile; ?>
    </p>

    but now i need to do the same for the wordpress pages - i managed to "embedd" the pages menu list in my static site but not the content of a specific site.

    the call for the pages list is as follows:

    <p><?php
    // turn off WordPress themes and include the WordPress core:
    define('WP_USE_THEMES', false);
    require($_SERVER['DOCUMENT_ROOT'] . 'test/wp/wp-blog-header.php');
    ?>
    
          <?php wp_list_pages('include=28&title_li=<h2>' . __('Gallerie') . '</h2>' ); ?>

    but now i want to show the content of the page with the id=28 on my html site.
    Does anyone knows how to do it? Would be really nice if someone could point me to the right wordpress function.

    Thank you in advance!

    zvenson

  2. zvenson
    Member
    Posted 4 years ago #

    okay found a solution which displays all pages on my site

    <?php $pageid = 28; ?>
    <?php
        $pages = get_pages($pageid);
        $count = 1;
        foreach($pages as $page)
        {
            $content = $page->post_content;
            if(!$content)
                continue;
            if($count >= 2)
                break;
            $count++;
            $content = apply_filters('the_content', $content);
        ?>
            <h2><a href=\"<?php echo get_page_link($page->ID) ?>\"><?php echo $page->post_title ?></a></h2>
            <div class=\"entry\"><?php echo $content ?></div>
        <?php
        }
    ?>

    when figured out how to select a certain site i`ll post it here...

  3. stvwlf
    Member
    Posted 4 years ago #

  4. zvenson
    Member
    Posted 4 years ago #

    Thanx for the reply stvwlf but the article you posted only covers how to implement posts not pages, my question was kind a different ... anyway see my second post to find out how to post wordpress pages on another html site.
    zvenson

  5. zvenson
    Member
    Posted 4 years ago #

    Sorry stvwlf i didn`t see this link on the page you have posted:
    query_posts() documentation

    this was very helpful for my problem -
    a nice solution to put any page - or post - content from wordpress on your html site could be like this (assuming its page id "63" you want to embedd to your site and wordpress is found at the ./wp/ folder:

    <?php
    // Include WordPress
    define('WP_USE_THEMES', false);
    require('./wp/wp-blog-header.php');
    query_posts('page_id=63');
    ?>
    <?php while (have_posts()): the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <?php the_content(); ?>
    <?php endwhile; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic