【问题标题】:Wordpress show recent post blogs in static pageWordpress 在静态页面中显示最近发布的博客
【发布时间】:2012-12-05 10:10:05
【问题描述】:

在 WordPress 中,我在 Reading 面板中显示带有 Front page displays 设置的静态首页。这很好用,但我想在此静态页面中显示最近的博客文章列表。我不确定在此静态页面中显示最近的博客文章的最佳方法是什么。那么有人可以指导我在静态页面中显示最近的博客吗?任何帮助和建议都将不胜感激。

【问题讨论】:

    标签: php wordpress wordpress-theming


    【解决方案1】:

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

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

    我使用&lt;?php echo substr($recent["post_content"], 0 , 150); ?&gt; 一段代码在页面上显示有限的字符。您可以根据需要更改它。

    【讨论】:

      【解决方案2】:

      您可以简单地使用 iframe 来包装您的查询并将 iframe 放置在任何 html 或 php 页面上,而无需触摸您当前的页面代码...查看此链接的详细说明:http://allnigeriansinspain.com/blog/show-wordpress-post-on-static-html-page/

      【讨论】:

        猜你喜欢
        • 2016-04-26
        • 2017-07-26
        • 1970-01-01
        • 2012-01-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-03-15
        • 2021-07-06
        相关资源
        最近更新 更多