【问题标题】:How do I show custom recent posts in WordPress?如何在 WordPress 中显示自定义的最近帖子?
【发布时间】:2021-11-03 07:08:15
【问题描述】:

现在显示如下:now it's showing like this

我希望它看起来像这样:I want it to look like this

【问题讨论】:

  • 看起来你需要提供更多信息。

标签: wordpress wordpress-theming custom-wordpress-pages wordpress-rest-api


【解决方案1】:

有两种方法:

  1. 在您的 WordPress 仪表板中,转到外观 » 小部件并将“最近的帖子”小部件添加到您的侧边栏。 https://prnt.sc/1rhjdc4

  2. 使用 wp 查询

$args = array(
    'post_type'      => 'product',
    'posts_per_page' => 10,
);
$loop = new WP_Query($args);
while ( $loop->have_posts() ) {
    $loop->the_post();
    ?>
    <div class="entry-content">
        <?php the_title(); ?>
        <?php the_content(); ?>
    </div>
    <?php
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-15
    • 1970-01-01
    • 2023-03-13
    相关资源
    最近更新 更多