Php 显示文章以及从wordpress到静态页面的边栏小部件

Php 显示文章以及从wordpress到静态页面的边栏小部件,php,wordpress,Php,Wordpress,我的网站位于主根目录中: 和wordpress博客在子文件夹中 现在我试图在wordpress之外的主页(index.php)上显示最近添加的帖子。到目前为止,它正在工作,文章正文显示在页面上。这就是我如何做到的(来自wordpress文档) 这是一个非常基本的例子。我的问题是,是否可以获取并显示整个帖子页面?比如标题、右边的小部件、帖子和评论/评论表单 只需使用调用侧栏即可。你的例子 <?php define('WP_USE_THEMES', false);

我的网站位于主根目录中:

和wordpress博客在子文件夹中

现在我试图在wordpress之外的主页(index.php)上显示最近添加的帖子。到目前为止,它正在工作,文章正文显示在页面上。这就是我如何做到的(来自wordpress文档)



这是一个非常基本的例子。我的问题是,是否可以获取并显示整个帖子页面?比如标题、右边的小部件、帖子和评论/评论表单

只需使用调用侧栏即可。你的例子

<?php
     define('WP_USE_THEMES', false);
     require('blog/wp-blog-header.php');
     $posts = get_posts('numberposts=1&order=ASC&orderby=post_title');
     foreach ($posts as $post) : setup_postdata( $post ); ?>

         <h1> <?php the_title(); ?> </h1>
         <h2> <?php the_date(); echo "<br />";?></h2>
         <h3 style="color: white;"> <?php the_content(); ?> </h3>
<?php endforeach; ?>

// calling the sidebar
<?php get_sidebar(); ?>

//调用侧边栏
现在侧边栏也将可见。可能需要一些html/css调整

<?php
     define('WP_USE_THEMES', false);
     require('blog/wp-blog-header.php');
     $posts = get_posts('numberposts=1&order=ASC&orderby=post_title');
     foreach ($posts as $post) : setup_postdata( $post ); ?>

         <h1> <?php the_title(); ?> </h1>
         <h2> <?php the_date(); echo "<br />";?></h2>
         <h3 style="color: white;"> <?php the_content(); ?> </h3>
<?php endforeach; ?>

// calling the sidebar
<?php get_sidebar(); ?>