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

将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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分