Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress在静态页面中显示最近发布的博客_Php_Wordpress_Wordpress Theming - Fatal编程技术网

Php Wordpress在静态页面中显示最近发布的博客

Php Wordpress在静态页面中显示最近发布的博客,php,wordpress,wordpress-theming,Php,Wordpress,Wordpress Theming,在WordPress中,我正在显示一个静态首页,其中阅读面板中的首页显示设置为。这很好,但我想在这个静态页面中显示最近的博客文章列表。我不确定在这个静态页面中显示最近的博客文章的最佳方法是什么。那么,有人能指导我在静态页面中显示最近的博客吗?任何帮助和建议都是值得欣赏的。在您想要显示博客内容的地方尝试这段代码 <div class="blog-post-wrap"> <?php $args = array( 'numberposts' => '4' ); $r

在WordPress中,我正在显示一个静态首页,其中
阅读面板中的
首页显示设置为
。这很好,但我想在这个静态页面中显示最近的博客文章列表。我不确定在这个静态页面中显示最近的博客文章的最佳方法是什么。那么,有人能指导我在静态页面中显示最近的博客吗?任何帮助和建议都是值得欣赏的。

在您想要显示博客内容的地方尝试这段代码

<div class="blog-post-wrap">
  <?php
  $args = array( 'numberposts' => '4' );
  $recent_posts = wp_get_recent_posts( $args );
  foreach( $recent_posts as $recent ){?>
    <div class="blog"><?php echo substr($recent["post_content"], 0 , 150); ?>
      <span class="link"><?php echo '<a href="' . get_permalink($recent["ID"]) . '" title="Reaed More '.$recent["post_title"].'" >' .   'Read More'.'</a> '; ?></span>
    </blog>
  <?php } ?>
</div>


我使用了
一段代码在页面上显示有限的字符。你可以根据自己的要求改变

您只需使用iframe包装查询,并将iframe放置在任何html或php页面上,而无需触摸当前页面代码。。。。请参阅此链接的详细说明: