doulongsi1831
2013-10-24 17:49
浏览 36
已采纳

将Wordpress页面集成到现有HTML站点中

I've run into a bit of a wall with a site I'm designing for a client. This was originally a very low budget static site but the client now needs the ability to edit some content from time to time. I've heard that you can just embed a wordpress page into existing HTML site and have followed the steps on the Codex site but can't seem to get it working. Any help is greatly appreciated.

So the wordpress page I'm trying to embed is the following:

http://octagonclubmiami.com/cs/

And the code I'm using is as follows:

This is posted at the beginning of the php file

<?php 
/* Short and sweet */
define('WP_USE_THEMES', false);
require('cs/wp-blog-header.php');
?>

And this is within the body of the php file

<?php
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : setup_postdata( $post ); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>    
<?php the_excerpt(); ?> 
<?php
endforeach;
?>

The actual page I'm trying to embed into is the following:

http://octagonclubmiami.com/community_service_test.php

As it sits it's currently displaying I guess some sample post instead of the page mentioned earlier.

Thanks in advance!

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duancong7573 2013-10-24 17:53
    已采纳

    The better solution (I think) is to use get_post() and specify the ID number of the post/page you wish to output:

    <?php
    $page = get_post( 'ID NUMBER HERE' );
    setup_postdata( $page ); 
    ?>
    
    <?php the_date(); echo "<br />"; ?>
    <?php the_title(); ?>    
    <?php the_excerpt(); ?>
    

    You can identify the post's ID number in the WordPress back-end.

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题