获取WordPress当日发布的文章

WordPress评论206阅读模式

获取WordPress当日发布的文章列表。

获取WordPress当日发布的文章-图片1

获取WordPress当日发布的文章

<?php
	$today = getdate();
	$args = array(
		'posts_per_page' => '20', // 篇数
		'ignore_sticky_posts' => true,
		'date_query' => array(
			array(
				'year'  => $today['year'],
				'month' => $today['mon'],
				'day'   => $today['mday'],
			),
		),
	);

	$query = new WP_Query( $args );
?>
<ul>
	<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();?>
		<li>
			<?php the_title( sprintf( '<a class="title" href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a>' ); ?>
		</li>
	<?php endwhile;?>
		<?php wp_reset_postdata(); ?>
	<?php else : ?>
		<li>
			暂无更新
		</li>
	<?php endif;?>
</ul>
获取WordPress当日发布的文章-图片2
如果需要调用一定时间段内的WordPress文章,可以通过下面的代码实现。 <?php $cat = '2'; // ...
176
获取WordPress当日发布的文章-图片2
获取本周发布的WordPress文章列表。 <?php $args = array( 'posts_per_page'...
4384

本站文章大部分始于原创,用于个人学习记录,可能对您有所帮助,仅供参考!

weinxin
我的微信
版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!
 
知更鸟
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

拖动滑块以完成验证