WordPress调用/获取最新文章
6个月前 (09-05)
WordPress调用最新文章的调用是大家经常使用也是同学们经常问的一个问题,如果您还不知道怎么调用WordPress调用最新文章下面就看看瑞课给您提供的几种WordPress调用最新文章方法吧。
WordPress调用最新文章
- <?php query_posts('showposts=5'); ?>
- <ul>
- <?php while (have_posts()) : the_post(); ?>
- <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
- <?php endwhile;?>
- </ul>
WordPress调用最新文章
<?php $rand_posts = get_posts('numberposts=5&category=1&orderby=date');foreach($rand_posts as $post) : ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach;?>
WordPress调用最新文章
<?php $rand_posts = get_posts('numberposts=10&orderby=date');foreach($rand_posts as $post) : ?>
<li><a href="<?php the_permalink(); ?>"> <?php echo mb_strimwidth(get_the_title(), 0, 32, ''); ?></a></li>
<?php endforeach;?>